Exemplo n.º 1
0
static cairo_int_status_t _cairo_xynth_surface_composite (cairo_operator_t cairo_operator, cairo_pattern_t *src_pattern, cairo_pattern_t *mask_pattern, void *abstract_surface, int src_x, int src_y, int mask_x, int mask_y, int dst_x, int dst_y, unsigned int width, unsigned int height)
{
	cairo_int_status_t status;
	cairo_xynth_surface_t *dst;
	cairo_xynth_surface_t *src;
	cairo_xynth_surface_t *mask;
	cairo_surface_attributes_t src_attr;
	cairo_surface_attributes_t mask_attr;
	ENTER();
	dst = (cairo_xynth_surface_t *) abstract_surface;
	status = _cairo_pattern_acquire_surfaces(src_pattern, mask_pattern, &dst->cairo, src_x, src_y, mask_x, mask_y, width, height, (cairo_surface_t **) &src, (cairo_surface_t **) &mask, &src_attr, &mask_attr);
	if (status) {
		return status;
	}
	status = _cairo_xynth_surface_set_attributes(src, &src_attr);
	if (status) {
		goto out;
	}
	if (mask) {
		status = _cairo_xynth_surface_set_attributes(mask, &mask_attr);
		if (status) {
			goto out;
		}
		s_render_composite(_cairo_xynth_operator(cairo_operator),
	                           src->render,
	                           mask->render,
	                           dst->render,
	                           src_x + src_attr.x_offset,
	                           src_y + src_attr.y_offset,
	                           mask_x + mask_attr.x_offset,
	                           mask_y + mask_attr.y_offset,
	                           dst_x, dst_y,
	                           width, height);
	} else {
		s_render_composite(_cairo_xynth_operator(cairo_operator),
		                   src->render,
		                   NULL,
		                   dst->render,
		                   src_x + src_attr.x_offset,
		                   src_y + src_attr.y_offset,
		                   0, 0,
		                   dst_x, dst_y,
		                   width, height);
	}
	if (!_cairo_operator_bounded_by_source(cairo_operator)) {
		status = _cairo_surface_composite_fixup_unbounded(&dst->cairo,
		                                                  &src_attr, src->render->width, src->render->height,
		                                                  mask ? &mask_attr : NULL,
		                                                  mask ? mask->render->width : 0,
		                                                  mask ? mask->render->height : 0,
		                                                  src_x, src_y,
		                                                  mask_x, mask_y,
		                                                  dst_x, dst_y,
		                                                  width, height);
	}
 out: 	if (mask) {
 		_cairo_pattern_release_surface(mask_pattern, &mask->cairo, &mask_attr);
 	}
 	_cairo_pattern_release_surface(src_pattern, &src->cairo, &src_attr);
	LEAVE();
	return CAIRO_STATUS_SUCCESS;
}
/**  @brief This function handles client driver shutdown
 *
 *  @param dev      A pointer to device structure
 *  @return         N/A
 */
void
woal_sdio_shutdown(struct device *dev)
{
	struct sdio_func *func = dev_to_sdio_func(dev);
	moal_handle *handle = NULL;
	struct sdio_mmc_card *cardp;
	mlan_ds_hs_cfg hscfg;
	int timeout = 0;
	int i;

	ENTER();
	PRINTM(MCMND, "<--- Enter woal_sdio_shutdown --->\n");
	cardp = sdio_get_drvdata(func);
	if (!cardp || !cardp->handle) {
		PRINTM(MERROR, "Card or moal_handle structure is not valid\n");
		LEAVE();
		return;
	}
	handle = cardp->handle;
	for (i = 0; i < handle->priv_num; i++)
		netif_device_detach(handle->priv[i]->netdev);
	if (shutdown_hs) {
		memset(&hscfg, 0, sizeof(mlan_ds_hs_cfg));
		hscfg.is_invoke_hostcmd = MFALSE;
		hscfg.conditions = SHUTDOWN_HOST_SLEEP_DEF_COND;
		hscfg.gap = SHUTDOWN_HOST_SLEEP_DEF_GAP;
		hscfg.gpio = SHUTDOWN_HOST_SLEEP_DEF_GPIO;
		if (woal_set_get_hs_params
		    (woal_get_priv(handle, MLAN_BSS_ROLE_ANY), MLAN_ACT_SET,
		     MOAL_IOCTL_WAIT, &hscfg) == MLAN_STATUS_FAILURE) {
			PRINTM(MERROR,
			       "Fail to set HS parameter in shutdown: 0x%x 0x%x 0x%x\n",
			       hscfg.conditions, hscfg.gap, hscfg.gpio);
			goto done;
		}
		/* Enable Host Sleep */
		handle->hs_activate_wait_q_woken = MFALSE;
		memset(&hscfg, 0, sizeof(mlan_ds_hs_cfg));
		hscfg.is_invoke_hostcmd = MTRUE;
		if (woal_set_get_hs_params
		    (woal_get_priv(handle, MLAN_BSS_ROLE_ANY), MLAN_ACT_SET,
		     MOAL_NO_WAIT, &hscfg) == MLAN_STATUS_FAILURE) {
			PRINTM(MERROR,
			       "Request HS enable failed in shutdown\n");
			goto done;
		}
		timeout =
			wait_event_interruptible_timeout(handle->
							 hs_activate_wait_q,
							 handle->
							 hs_activate_wait_q_woken,
							 HS_ACTIVE_TIMEOUT);
		if (handle->hs_activated == MTRUE)
			PRINTM(MMSG, "HS actived in shutdown\n");
		else
			PRINTM(MMSG, "Fail to enable HS in shutdown\n");
	}
done:
	PRINTM(MCMND, "<--- Leave woal_sdio_shutdown --->\n");
	LEAVE();
	return;
}
Exemplo n.º 3
0
/*
 * Function that does the real stuff.
 */
bpf_filter_func
bpf_jit_compile(struct bpf_insn *prog, u_int nins, size_t *size)
{
	bpf_bin_stream stream;
	struct bpf_insn *ins;
	int flags, fret, fpkt, fmem, fjmp, flen;
	u_int i, pass;

	/*
	 * NOTE: Do not modify the name of this variable, as it's used by
	 * the macros to emit code.
	 */
	emit_func emitm;

	flags = bpf_jit_optimize(prog, nins);
	fret = (flags & BPF_JIT_FRET) != 0;
	fpkt = (flags & BPF_JIT_FPKT) != 0;
	fmem = (flags & BPF_JIT_FMEM) != 0;
	fjmp = (flags & BPF_JIT_FJMP) != 0;
	flen = (flags & BPF_JIT_FLEN) != 0;

	if (fret)
		nins = 1;

	memset(&stream, 0, sizeof(stream));

	/* Allocate the reference table for the jumps. */
	if (fjmp) {
#ifdef _KERNEL
		stream.refs = malloc((nins + 1) * sizeof(u_int), M_BPFJIT,
		    M_NOWAIT | M_ZERO);
#else
		stream.refs = calloc(nins + 1, sizeof(u_int));
#endif
		if (stream.refs == NULL)
			return (NULL);
	}

	/*
	 * The first pass will emit the lengths of the instructions
	 * to create the reference table.
	 */
	emitm = emit_length;

	for (pass = 0; pass < 2; pass++) {
		ins = prog;

		/* Create the procedure header. */
		if (fmem) {
			PUSH(RBP);
			MOVrq(RSP, RBP);
			SUBib(BPF_MEMWORDS * sizeof(uint32_t), RSP);
		}
		if (flen)
			MOVrd2(ESI, R9D);
		if (fpkt) {
			MOVrq2(RDI, R8);
			MOVrd(EDX, EDI);
		}

		for (i = 0; i < nins; i++) {
			stream.bpf_pc++;

			switch (ins->code) {
			default:
#ifdef _KERNEL
				return (NULL);
#else
				abort();
#endif

			case BPF_RET|BPF_K:
				MOVid(ins->k, EAX);
				if (fmem)
					LEAVE();
				RET();
				break;

			case BPF_RET|BPF_A:
				if (fmem)
					LEAVE();
				RET();
				break;

			case BPF_LD|BPF_W|BPF_ABS:
				MOVid(ins->k, ESI);
				CMPrd(EDI, ESI);
				JAb(12);
				MOVrd(EDI, ECX);
				SUBrd(ESI, ECX);
				CMPid(sizeof(int32_t), ECX);
				if (fmem) {
					JAEb(4);
					ZEROrd(EAX);
					LEAVE();
				} else {
					JAEb(3);
					ZEROrd(EAX);
				}
				RET();
				MOVrq3(R8, RCX);
				MOVobd(RCX, RSI, EAX);
				BSWAP(EAX);
				break;

			case BPF_LD|BPF_H|BPF_ABS:
				ZEROrd(EAX);
				MOVid(ins->k, ESI);
				CMPrd(EDI, ESI);
				JAb(12);
				MOVrd(EDI, ECX);
				SUBrd(ESI, ECX);
				CMPid(sizeof(int16_t), ECX);
				if (fmem) {
					JAEb(2);
					LEAVE();
				} else
					JAEb(1);
				RET();
				MOVrq3(R8, RCX);
				MOVobw(RCX, RSI, AX);
				SWAP_AX();
				break;

			case BPF_LD|BPF_B|BPF_ABS:
				ZEROrd(EAX);
				MOVid(ins->k, ESI);
				CMPrd(EDI, ESI);
				if (fmem) {
					JBb(2);
					LEAVE();
				} else
					JBb(1);
				RET();
				MOVrq3(R8, RCX);
				MOVobb(RCX, RSI, AL);
				break;

			case BPF_LD|BPF_W|BPF_LEN:
				MOVrd3(R9D, EAX);
				break;

			case BPF_LDX|BPF_W|BPF_LEN:
				MOVrd3(R9D, EDX);
				break;

			case BPF_LD|BPF_W|BPF_IND:
				CMPrd(EDI, EDX);
				JAb(27);
				MOVid(ins->k, ESI);
				MOVrd(EDI, ECX);
				SUBrd(EDX, ECX);
				CMPrd(ESI, ECX);
				JBb(14);
				ADDrd(EDX, ESI);
				MOVrd(EDI, ECX);
				SUBrd(ESI, ECX);
				CMPid(sizeof(int32_t), ECX);
				if (fmem) {
					JAEb(4);
					ZEROrd(EAX);
					LEAVE();
				} else {
					JAEb(3);
					ZEROrd(EAX);
				}
				RET();
				MOVrq3(R8, RCX);
				MOVobd(RCX, RSI, EAX);
				BSWAP(EAX);
				break;

			case BPF_LD|BPF_H|BPF_IND:
				ZEROrd(EAX);
				CMPrd(EDI, EDX);
				JAb(27);
				MOVid(ins->k, ESI);
				MOVrd(EDI, ECX);
				SUBrd(EDX, ECX);
				CMPrd(ESI, ECX);
				JBb(14);
				ADDrd(EDX, ESI);
				MOVrd(EDI, ECX);
				SUBrd(ESI, ECX);
				CMPid(sizeof(int16_t), ECX);
				if (fmem) {
					JAEb(2);
					LEAVE();
				} else
					JAEb(1);
				RET();
				MOVrq3(R8, RCX);
				MOVobw(RCX, RSI, AX);
				SWAP_AX();
				break;

			case BPF_LD|BPF_B|BPF_IND:
				ZEROrd(EAX);
				CMPrd(EDI, EDX);
				JAEb(13);
				MOVid(ins->k, ESI);
				MOVrd(EDI, ECX);
				SUBrd(EDX, ECX);
				CMPrd(ESI, ECX);
				if (fmem) {
					JAb(2);
					LEAVE();
				} else
					JAb(1);
				RET();
				MOVrq3(R8, RCX);
				ADDrd(EDX, ESI);
				MOVobb(RCX, RSI, AL);
				break;

			case BPF_LDX|BPF_MSH|BPF_B:
				MOVid(ins->k, ESI);
				CMPrd(EDI, ESI);
				if (fmem) {
					JBb(4);
					ZEROrd(EAX);
					LEAVE();
				} else {
					JBb(3);
					ZEROrd(EAX);
				}
				RET();
				ZEROrd(EDX);
				MOVrq3(R8, RCX);
				MOVobb(RCX, RSI, DL);
				ANDib(0x0f, DL);
				SHLib(2, EDX);
				break;

			case BPF_LD|BPF_IMM:
				MOVid(ins->k, EAX);
				break;

			case BPF_LDX|BPF_IMM:
				MOVid(ins->k, EDX);
				break;

			case BPF_LD|BPF_MEM:
				MOVid(ins->k * sizeof(uint32_t), ESI);
				MOVobd(RSP, RSI, EAX);
				break;

			case BPF_LDX|BPF_MEM:
				MOVid(ins->k * sizeof(uint32_t), ESI);
				MOVobd(RSP, RSI, EDX);
				break;

			case BPF_ST:
				/*
				 * XXX this command and the following could
				 * be optimized if the previous instruction
				 * was already of this type
				 */
				MOVid(ins->k * sizeof(uint32_t), ESI);
				MOVomd(EAX, RSP, RSI);
				break;

			case BPF_STX:
				MOVid(ins->k * sizeof(uint32_t), ESI);
				MOVomd(EDX, RSP, RSI);
				break;

			case BPF_JMP|BPF_JA:
				JUMP(ins->k);
				break;

			case BPF_JMP|BPF_JGT|BPF_K:
				if (ins->jt == ins->jf) {
					JUMP(ins->jt);
					break;
				}
				CMPid(ins->k, EAX);
				JCC(JA, JBE);
				break;

			case BPF_JMP|BPF_JGE|BPF_K:
				if (ins->jt == ins->jf) {
					JUMP(ins->jt);
					break;
				}
				CMPid(ins->k, EAX);
				JCC(JAE, JB);
				break;

			case BPF_JMP|BPF_JEQ|BPF_K:
				if (ins->jt == ins->jf) {
					JUMP(ins->jt);
					break;
				}
				CMPid(ins->k, EAX);
				JCC(JE, JNE);
				break;

			case BPF_JMP|BPF_JSET|BPF_K:
				if (ins->jt == ins->jf) {
					JUMP(ins->jt);
					break;
				}
				TESTid(ins->k, EAX);
				JCC(JNE, JE);
				break;

			case BPF_JMP|BPF_JGT|BPF_X:
				if (ins->jt == ins->jf) {
					JUMP(ins->jt);
					break;
				}
				CMPrd(EDX, EAX);
				JCC(JA, JBE);
				break;

			case BPF_JMP|BPF_JGE|BPF_X:
				if (ins->jt == ins->jf) {
					JUMP(ins->jt);
					break;
				}
				CMPrd(EDX, EAX);
				JCC(JAE, JB);
				break;

			case BPF_JMP|BPF_JEQ|BPF_X:
				if (ins->jt == ins->jf) {
					JUMP(ins->jt);
					break;
				}
				CMPrd(EDX, EAX);
				JCC(JE, JNE);
				break;

			case BPF_JMP|BPF_JSET|BPF_X:
				if (ins->jt == ins->jf) {
					JUMP(ins->jt);
					break;
				}
				TESTrd(EDX, EAX);
				JCC(JNE, JE);
				break;

			case BPF_ALU|BPF_ADD|BPF_X:
				ADDrd(EDX, EAX);
				break;

			case BPF_ALU|BPF_SUB|BPF_X:
				SUBrd(EDX, EAX);
				break;

			case BPF_ALU|BPF_MUL|BPF_X:
				MOVrd(EDX, ECX);
				MULrd(EDX);
				MOVrd(ECX, EDX);
				break;

			case BPF_ALU|BPF_DIV|BPF_X:
				TESTrd(EDX, EDX);
				if (fmem) {
					JNEb(4);
					ZEROrd(EAX);
					LEAVE();
				} else {
					JNEb(3);
					ZEROrd(EAX);
				}
				RET();
				MOVrd(EDX, ECX);
				ZEROrd(EDX);
				DIVrd(ECX);
				MOVrd(ECX, EDX);
				break;

			case BPF_ALU|BPF_AND|BPF_X:
				ANDrd(EDX, EAX);
				break;

			case BPF_ALU|BPF_OR|BPF_X:
				ORrd(EDX, EAX);
				break;

			case BPF_ALU|BPF_LSH|BPF_X:
				MOVrd(EDX, ECX);
				SHL_CLrb(EAX);
				break;

			case BPF_ALU|BPF_RSH|BPF_X:
				MOVrd(EDX, ECX);
				SHR_CLrb(EAX);
				break;

			case BPF_ALU|BPF_ADD|BPF_K:
				ADD_EAXi(ins->k);
				break;

			case BPF_ALU|BPF_SUB|BPF_K:
				SUB_EAXi(ins->k);
				break;

			case BPF_ALU|BPF_MUL|BPF_K:
				MOVrd(EDX, ECX);
				MOVid(ins->k, EDX);
				MULrd(EDX);
				MOVrd(ECX, EDX);
				break;

			case BPF_ALU|BPF_DIV|BPF_K:
				MOVrd(EDX, ECX);
				ZEROrd(EDX);
				MOVid(ins->k, ESI);
				DIVrd(ESI);
				MOVrd(ECX, EDX);
				break;

			case BPF_ALU|BPF_AND|BPF_K:
				ANDid(ins->k, EAX);
				break;

			case BPF_ALU|BPF_OR|BPF_K:
				ORid(ins->k, EAX);
				break;

			case BPF_ALU|BPF_LSH|BPF_K:
				SHLib((ins->k) & 0xff, EAX);
				break;

			case BPF_ALU|BPF_RSH|BPF_K:
				SHRib((ins->k) & 0xff, EAX);
				break;

			case BPF_ALU|BPF_NEG:
				NEGd(EAX);
				break;

			case BPF_MISC|BPF_TAX:
				MOVrd(EAX, EDX);
				break;

			case BPF_MISC|BPF_TXA:
				MOVrd(EDX, EAX);
				break;
			}
			ins++;
		}

		if (pass > 0)
			continue;

		*size = stream.cur_ip;
#ifdef _KERNEL
		stream.ibuf = malloc(*size, M_BPFJIT, M_NOWAIT);
		if (stream.ibuf == NULL)
			break;
#else
		stream.ibuf = mmap(NULL, *size, PROT_READ | PROT_WRITE,
		    MAP_ANON, -1, 0);
		if (stream.ibuf == MAP_FAILED) {
			stream.ibuf = NULL;
			break;
		}
#endif

		/*
		 * Modify the reference table to contain the offsets and
		 * not the lengths of the instructions.
		 */
		if (fjmp)
			for (i = 1; i < nins + 1; i++)
				stream.refs[i] += stream.refs[i - 1];

		/* Reset the counters. */
		stream.cur_ip = 0;
		stream.bpf_pc = 0;

		/* The second pass creates the actual code. */
		emitm = emit_code;
	}

	/*
	 * The reference table is needed only during compilation,
	 * now we can free it.
	 */
	if (fjmp)
#ifdef _KERNEL
		free(stream.refs, M_BPFJIT);
#else
		free(stream.refs);
#endif

#ifndef _KERNEL
	if (stream.ibuf != NULL &&
	    mprotect(stream.ibuf, *size, PROT_READ | PROT_EXEC) != 0) {
		munmap(stream.ibuf, *size);
		stream.ibuf = NULL;
	}
#endif

	return ((bpf_filter_func)stream.ibuf);
}
static void
SMI_CrtcPrepare(xf86CrtcPtr crtc)
{
    ENTER();
    LEAVE();
}
Exemplo n.º 5
0
/**
 *  @brief Deaggregate the received AMSDU packet
 *
 *  @param priv		A pointer to mlan_private structure
 *  @param pmbuf	A pointer to aggregated data packet
 *
 *  @return		MLAN_STATUS_SUCCESS --success, otherwise fail
 */
mlan_status
wlan_11n_deaggregate_pkt(mlan_private * priv, pmlan_buffer pmbuf)
{
    t_u16 pkt_len;
    int total_pkt_len;
    t_u8 *data;
    int pad;
    mlan_status ret = MLAN_STATUS_FAILURE;
    RxPacketHdr_t *prx_pkt;
    mlan_buffer *daggr_mbuf = MNULL;
    mlan_adapter *pmadapter = priv->adapter;
    t_u8 rfc1042_eth_hdr[MLAN_MAC_ADDR_LENGTH] = { 0xaa, 0xaa, 0x03,
        0x00, 0x00, 0x00
    };

    ENTER();

    data = (t_u8 *) (pmbuf->pbuf + pmbuf->data_offset);
    total_pkt_len = pmbuf->data_len;

    /* Sanity test */
    if (total_pkt_len > MLAN_RX_DATA_BUF_SIZE) {
        PRINTM(MERROR, "Total packet length greater than tx buffer"
               " size %d\n", total_pkt_len);
        goto done;
    }

    pmbuf->use_count = wlan_11n_get_num_aggrpkts(data, total_pkt_len);

    while (total_pkt_len > 0) {
        prx_pkt = (RxPacketHdr_t *) data;
        /* Length will be in network format, change it to host */
        pkt_len = mlan_ntohs((*(t_u16 *) (data + (2 * MLAN_MAC_ADDR_LENGTH))));
        if (pkt_len > total_pkt_len) {
            PRINTM(MERROR,
                   "Error in packet length: total_pkt_len = %d, pkt_len = %d\n",
                   total_pkt_len, pkt_len);
            break;
        }

        pad = (((pkt_len + sizeof(Eth803Hdr_t)) & 3)) ?
            (4 - ((pkt_len + sizeof(Eth803Hdr_t)) & 3)) : 0;

        total_pkt_len -= pkt_len + pad + sizeof(Eth803Hdr_t);

        if (memcmp(pmadapter, &prx_pkt->rfc1042_hdr,
                   rfc1042_eth_hdr, sizeof(rfc1042_eth_hdr)) == 0) {
            memmove(pmadapter, data + LLC_SNAP_LEN, data, (2 *
                                                           MLAN_MAC_ADDR_LENGTH));
            data += LLC_SNAP_LEN;
            pkt_len += sizeof(Eth803Hdr_t) - LLC_SNAP_LEN;
        } else {
            *(t_u16 *) (data + (2 * MLAN_MAC_ADDR_LENGTH))
                = (t_u16) 0;
            pkt_len += sizeof(Eth803Hdr_t);
        }
        daggr_mbuf = wlan_alloc_mlan_buffer(pmadapter, pkt_len, 0, MFALSE);
        if (daggr_mbuf == MNULL) {
            PRINTM(MERROR, "Error allocating daggr mlan_buffer\n");
            LEAVE();
            return MLAN_STATUS_FAILURE;
        }
        daggr_mbuf->bss_index = pmbuf->bss_index;
        daggr_mbuf->buf_type = pmbuf->buf_type;
        daggr_mbuf->data_len = pkt_len;
        daggr_mbuf->in_ts_sec = pmbuf->in_ts_sec;
        daggr_mbuf->in_ts_usec = pmbuf->in_ts_usec;
        daggr_mbuf->pparent = pmbuf;
        daggr_mbuf->priority = pmbuf->priority;
        memcpy(pmadapter, daggr_mbuf->pbuf + daggr_mbuf->data_offset, data,
               pkt_len);

#ifdef UAP_SUPPORT
        if (GET_BSS_ROLE(priv) == MLAN_BSS_ROLE_UAP)
            ret = wlan_uap_recv_packet(priv, daggr_mbuf);
        else
#endif /* UAP_SUPPORT */
            ret =
                pmadapter->callbacks.moal_recv_packet(pmadapter->pmoal_handle,
                                                      daggr_mbuf);

        switch (ret) {
        case MLAN_STATUS_PENDING:
            break;
        case MLAN_STATUS_FAILURE:
            PRINTM(MERROR, "Deaggr, send to moal failed\n");
            daggr_mbuf->status_code = MLAN_ERROR_PKT_INVALID;
        case MLAN_STATUS_SUCCESS:
            wlan_recv_packet_complete(pmadapter, daggr_mbuf, ret);
            break;
        default:
            break;
        }

        data += pkt_len + pad;
    }

  done:
    LEAVE();
    return ret;
}
/**
 *  @brief This function initializes the adapter structure
 *  		and sets default values to the members of adapter.
 *
 *  @param pmadapter	A pointer to mlan_adapter structure
 *
 *  @return		N/A
 */
t_void
wlan_init_adapter(pmlan_adapter pmadapter)
{
    ENTER();

    pmadapter->cmd_sent = MFALSE;
    pmadapter->data_sent = MFALSE;
    pmadapter->cmd_resp_received = MFALSE;
    pmadapter->event_received = MFALSE;
    pmadapter->data_received = MFALSE;

    pmadapter->cmd_timer_is_set = MFALSE;

    /* PnP and power profile */
    pmadapter->surprise_removed = MFALSE;

    /* Status variables */
    pmadapter->hw_status = WlanHardwareStatusInitializing;

    /* Scan type */
    pmadapter->scan_type = HostCmd_SCAN_TYPE_ACTIVE;
    /* Scan mode */
    pmadapter->scan_mode = HostCmd_BSS_TYPE_ANY;
    /* Scan time */
    pmadapter->specific_scan_time = MRVDRV_SPECIFIC_SCAN_CHAN_TIME;
    pmadapter->active_scan_time = MRVDRV_ACTIVE_SCAN_CHAN_TIME;
    pmadapter->passive_scan_time = MRVDRV_PASSIVE_SCAN_CHAN_TIME;

    pmadapter->num_in_scan_table = 0;
    memset(pmadapter->pscan_table, 0,
           (sizeof(BSSDescriptor_t) * MRVDRV_MAX_BSSID_LIST));
    pmadapter->scan_probes = 0;

    memset(pmadapter->bcn_buf, 0, sizeof(pmadapter->bcn_buf));
    pmadapter->pbcn_buf_end = pmadapter->bcn_buf;

    pmadapter->radio_on = RADIO_ON;

    pmadapter->ps_mode = Wlan802_11PowerModeCAM;
    pmadapter->multiple_dtim = MRVDRV_DEFAULT_MULTIPLE_DTIM;

    pmadapter->ps_state = PS_STATE_FULL_POWER;
    pmadapter->need_to_wakeup = MFALSE;
    pmadapter->local_listen_interval = 0;       /* default value in firmware
                                                   will be used */

    pmadapter->pm_wakeup_card_req = MFALSE;
    pmadapter->pm_wakeup_fw_try = MFALSE;

    pmadapter->max_tx_buf_size = MLAN_TX_DATA_BUF_SIZE_2K;
    pmadapter->tx_buf_size = MLAN_TX_DATA_BUF_SIZE_2K;

    pmadapter->is_hs_configured = MFALSE;
    pmadapter->hs_cfg.conditions = HOST_SLEEP_CFG_CANCEL;
    pmadapter->hs_cfg.gpio = 0;
    pmadapter->hs_cfg.gap = 0;
    pmadapter->hs_activated = MFALSE;

    memset(pmadapter->event_body, 0, sizeof(pmadapter->event_body));
    pmadapter->hw_dot_11n_dev_cap = 0;
    pmadapter->hw_dev_mcs_support = 0;
    pmadapter->usr_dot_11n_dev_cap = 0;
    pmadapter->usr_dev_mcs_support = 0;
    pmadapter->chan_offset = 0;

    /* Initialize 802.11d */
    wlan_11d_init(pmadapter);

    wlan_wmm_init(pmadapter);
    util_init_list_head(&pmadapter->rx_data_queue, MTRUE,
                        pmadapter->callbacks.moal_init_lock);

    memset(&pmadapter->sleep_cfm_buf.ps_cfm_sleep, 0,
           sizeof(PS_CMD_ConfirmSleep));
    pmadapter->sleep_cfm_buf.ps_cfm_sleep.command =
        wlan_cpu_to_le16(HostCmd_CMD_802_11_PS_MODE);
    pmadapter->sleep_cfm_buf.ps_cfm_sleep.size =
        wlan_cpu_to_le16(sizeof(PS_CMD_ConfirmSleep));
    pmadapter->sleep_cfm_buf.ps_cfm_sleep.result = 0;
    pmadapter->sleep_cfm_buf.ps_cfm_sleep.action =
        wlan_cpu_to_le16(HostCmd_SubCmd_Sleep_Confirmed);

    memset(&pmadapter->sleep_params, 0, sizeof(pmadapter->sleep_params));
    memset(&pmadapter->sleep_period, 0, sizeof(pmadapter->sleep_period));
    pmadapter->tx_lock_flag = MFALSE;
    pmadapter->null_pkt_interval = 0;
    pmadapter->fw_bands = 0;
    pmadapter->config_bands = 0;
    pmadapter->adhoc_start_band = 0;
    pmadapter->pscan_channels = MNULL;
    pmadapter->fw_release_number = 0;
    pmadapter->fw_cap_info = 0;
    memset(&pmadapter->upld_buf, 0, sizeof(pmadapter->upld_buf));
    pmadapter->upld_len = 0;
    pmadapter->event_cause = 0;
    memset(&pmadapter->region_channel, 0, sizeof(pmadapter->region_channel));
    pmadapter->region_code = 0;
    pmadapter->bcn_miss_time_out = DEFAULT_BCN_MISS_TIMEOUT;
    pmadapter->adhoc_awake_period = 0;
    memset(&pmadapter->arp_filter, 0, sizeof(pmadapter->arp_filter));
    pmadapter->arp_filter_size = 0;

    LEAVE();
    return;
}
/**
 *  @brief  This function issues commands to initialize firmware
 *
 *  @param pmadapter		A pointer to mlan_adapter
 *
 *  @return		MLAN_STATUS_SUCCESS or error code
 */
mlan_status
wlan_init_cmd(IN pmlan_adapter pmadapter)
{
    mlan_status ret = MLAN_STATUS_SUCCESS;
    pmlan_private priv = MNULL;
    t_s32 i = 0;
    t_u16 enable = MTRUE;
    mlan_ds_11n_amsdu_aggr_ctrl amsdu_aggr_ctrl;

    ENTER();

    if (pmadapter->priv[0]) {
        priv = pmadapter->priv[0];

        /*
         * Read MAC address from HW
         */
        ret = wlan_prepare_cmd(priv,
                               HostCmd_CMD_GET_HW_SPEC,
                               HostCmd_ACT_GEN_GET, 0, MNULL, MNULL);
        if (ret) {
            ret = MLAN_STATUS_FAILURE;
            goto done;
        }

        /* Reconfgiure tx buf size */
        ret = wlan_prepare_cmd(priv,
                               HostCmd_CMD_RECONFIGURE_TX_BUFF,
                               HostCmd_ACT_GEN_SET,
                               0, MNULL, &pmadapter->tx_buf_size);
        if (ret) {
            ret = MLAN_STATUS_FAILURE;
            goto done;
        }
    }

    for (i = 0; i < MLAN_MAX_BSS_NUM; i++) {
        if (pmadapter->priv[i]) {
            priv = pmadapter->priv[i];

            /* get tx rate */
            ret = wlan_prepare_cmd(priv,
                                   HostCmd_CMD_TX_RATE_CFG,
                                   HostCmd_ACT_GEN_GET, 0, MNULL, MNULL);
            if (ret) {
                ret = MLAN_STATUS_FAILURE;
                goto done;
            }
            priv->data_rate = 0;

            /* get tx power */
            ret = wlan_prepare_cmd(priv,
                                   HostCmd_CMD_TXPWR_CFG,
                                   HostCmd_ACT_GEN_GET, 0, MNULL, MNULL);
            if (ret) {
                ret = MLAN_STATUS_FAILURE;
                goto done;
            }
            /* set ibss coalescing_status */
            ret = wlan_prepare_cmd(priv,
                                   HostCmd_CMD_802_11_IBSS_COALESCING_STATUS,
                                   HostCmd_ACT_GEN_SET, 0, MNULL, &enable);
            if (ret) {
                ret = MLAN_STATUS_FAILURE;
                goto done;
            }

            memset(&amsdu_aggr_ctrl, 0, sizeof(amsdu_aggr_ctrl));
            amsdu_aggr_ctrl.enable = MLAN_ACT_ENABLE;
            /* Send request to firmware */
            ret = wlan_prepare_cmd(priv,
                                   HostCmd_CMD_AMSDU_AGGR_CTRL,
                                   HostCmd_ACT_GEN_SET, 0, MNULL,
                                   (t_void *) & amsdu_aggr_ctrl);
            if (ret) {
                ret = MLAN_STATUS_FAILURE;
                goto done;
            }
            /* MAC Control must be the last command in init_fw */
            /* set MAC Control */
            ret = wlan_prepare_cmd(priv,
                                   HostCmd_CMD_MAC_CONTROL,
                                   HostCmd_ACT_GEN_SET,
                                   0, MNULL, &priv->curr_pkt_filter);
            if (ret) {
                ret = MLAN_STATUS_FAILURE;
                goto done;
            }
        }
    }

    ret = MLAN_STATUS_PENDING;
done:
    LEAVE();
    return ret;
}
Exemplo n.º 8
0
/**
 *  @brief This function generates domain_info from parsed_region_chan
 *
 *  @param pmadapter            Pointer to mlan_adapter structure
 *  @param parsed_region_chan   Pointer to parsed_region_chan_11d_t
 *
 *  @return                     MLAN_STATUS_SUCCESS
 */
static mlan_status
wlan_11d_generate_domain_info(pmlan_adapter pmadapter,
			      parsed_region_chan_11d_t * parsed_region_chan)
{
	t_u8 no_of_sub_band = 0;
	t_u8 no_of_chan = parsed_region_chan->no_of_chan;
	t_u8 no_of_parsed_chan = 0;
	t_u8 first_chan = 0, next_chan = 0, max_pwr = 0;
	t_u8 i, flag = MFALSE;
	wlan_802_11d_domain_reg_t *domain_info = &pmadapter->domain_reg;

	ENTER();

	/* Should be only place that clear domain_reg (besides init) */
	memset(pmadapter, domain_info, 0, sizeof(wlan_802_11d_domain_reg_t));

	/* Set country code */
	memcpy(pmadapter, domain_info->country_code,
	       wlan_11d_code_2_region(pmadapter, (t_u8) pmadapter->region_code),
	       COUNTRY_CODE_LEN);

	PRINTM(MINFO, "11D: Number of channel = %d\n", no_of_chan);
	HEXDUMP("11D: parsed_region_chan", (t_u8 *) parsed_region_chan,
		sizeof(parsed_region_chan_11d_t));

	/* Set channel and power */
	for (i = 0; i < no_of_chan; i++) {
		if (!flag) {
			flag = MTRUE;
			next_chan = first_chan =
				parsed_region_chan->chan_pwr[i].chan;
			max_pwr = parsed_region_chan->chan_pwr[i].pwr;
			no_of_parsed_chan = 1;
			continue;
		}

		if (parsed_region_chan->chan_pwr[i].chan == next_chan + 1 &&
		    parsed_region_chan->chan_pwr[i].pwr == max_pwr) {
			next_chan++;
			no_of_parsed_chan++;
		} else {
			domain_info->sub_band[no_of_sub_band].first_chan =
				first_chan;
			domain_info->sub_band[no_of_sub_band].no_of_chan =
				no_of_parsed_chan;
			domain_info->sub_band[no_of_sub_band].max_tx_pwr =
				max_pwr;
			no_of_sub_band++;
			no_of_parsed_chan = 1;
			next_chan = first_chan =
				parsed_region_chan->chan_pwr[i].chan;
			max_pwr = parsed_region_chan->chan_pwr[i].pwr;
		}
	}

	if (flag) {
		domain_info->sub_band[no_of_sub_band].first_chan = first_chan;
		domain_info->sub_band[no_of_sub_band].no_of_chan =
			no_of_parsed_chan;
		domain_info->sub_band[no_of_sub_band].max_tx_pwr = max_pwr;
		no_of_sub_band++;
	}
	domain_info->no_of_sub_band = no_of_sub_band;

	PRINTM(MINFO, "11D: Number of sub-band =0x%x\n",
	       domain_info->no_of_sub_band);
	HEXDUMP("11D: domain_info", (t_u8 *) domain_info,
		COUNTRY_CODE_LEN + 1 +
		sizeof(IEEEtypes_SubbandSet_t) * no_of_sub_band);
	LEAVE();
	return MLAN_STATUS_SUCCESS;
}
Exemplo n.º 9
0
/**
 *  @brief This function processes the country info present in BSSDescriptor.
 *
 *  @param pmpriv       A pointer to mlan_private structure
 *  @param pbss_desc     A pointer to BSSDescriptor_t
 *
 *  @return             MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE
 */
static mlan_status
wlan_11d_process_country_info(mlan_private * pmpriv,
			      BSSDescriptor_t * pbss_desc)
{
	mlan_adapter *pmadapter = pmpriv->adapter;
	parsed_region_chan_11d_t region_chan;
	parsed_region_chan_11d_t *parsed_region_chan =
		&pmadapter->parsed_region_chan;
	t_u16 i, j, num_chan_added = 0;

	ENTER();

	memset(pmadapter, &region_chan, 0, sizeof(parsed_region_chan_11d_t));

	/* Parse 11D country info */
	if (wlan_11d_parse_domain_info(pmadapter, &pbss_desc->country_info,
				       (t_u8) pbss_desc->bss_band,
				       &region_chan) != MLAN_STATUS_SUCCESS) {
		LEAVE();
		return MLAN_STATUS_FAILURE;
	}

	if (parsed_region_chan->no_of_chan != 0) {
		/*
		 * Check if the channel number already exists in the
		 * chan-power table of parsed_region_chan
		 */
		for (i = 0; (i < region_chan.no_of_chan && i < MAX_NO_OF_CHAN);
		     i++) {
			for (j = 0;
			     (j < parsed_region_chan->no_of_chan &&
			      j < MAX_NO_OF_CHAN); j++) {
				/*
				 * Channel already exists, update the tx power with new tx
				 * power, since country IE is valid here.
				 */
				if (region_chan.chan_pwr[i].chan ==
				    parsed_region_chan->chan_pwr[j].chan &&
				    region_chan.chan_pwr[i].band ==
				    parsed_region_chan->chan_pwr[j].band) {
					parsed_region_chan->chan_pwr[j].pwr =
						region_chan.chan_pwr[i].pwr;
					break;
				}
			}

			if (j == parsed_region_chan->no_of_chan &&
			    j < MAX_NO_OF_CHAN) {
				/*
				 * Channel does not exist in the channel power table,
				 * update this new chan and tx_power to the channel power table
				 */
				parsed_region_chan->
					chan_pwr[parsed_region_chan->
						 no_of_chan +
						 num_chan_added].chan =
					region_chan.chan_pwr[i].chan;
				parsed_region_chan->
					chan_pwr[parsed_region_chan->
						 no_of_chan +
						 num_chan_added].band =
					region_chan.chan_pwr[i].band;
				parsed_region_chan->
					chan_pwr[parsed_region_chan->
						 no_of_chan +
						 num_chan_added].pwr =
					region_chan.chan_pwr[i].pwr;
				parsed_region_chan->
					chan_pwr[parsed_region_chan->
						 no_of_chan +
						 num_chan_added].ap_seen =
					MFALSE;
				num_chan_added++;
			}
		}
		parsed_region_chan->no_of_chan += num_chan_added;
	} else {
		/* Parsed region is empty, copy the first one */
		memcpy(pmadapter, parsed_region_chan,
		       &region_chan, sizeof(parsed_region_chan_11d_t));
	}

	LEAVE();
	return MLAN_STATUS_SUCCESS;
}
Exemplo n.º 10
0
/**
 *  @brief This function generates 11D info from user specified regioncode
 *         and download to FW
 *
 *  @param pmpriv       A pointer to mlan_private structure
 *  @param band         Band to create
 *
 *  @return             MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE
 */
mlan_status
wlan_11d_create_dnld_countryinfo(mlan_private * pmpriv, t_u8 band)
{
	mlan_status ret = MLAN_STATUS_SUCCESS;
	mlan_adapter *pmadapter = pmpriv->adapter;
	region_chan_t *region_chan;
	parsed_region_chan_11d_t parsed_region_chan;
	t_u8 j;

	ENTER();

	/* Only valid if 11D is enabled */
	if (wlan_11d_is_enabled(pmpriv)) {

		PRINTM(MINFO, "11D: Band[%d]\n", band);

		/* Update parsed_region_chan; download domain info to FW */

		/* Find region channel */
		for (j = 0; j < MAX_REGION_CHANNEL_NUM; j++) {
			region_chan = &pmadapter->region_channel[j];

			PRINTM(MINFO, "11D: [%d] region_chan->Band[%d]\n", j,
			       region_chan->band);

			if (!region_chan || !region_chan->valid ||
			    !region_chan->pcfp)
				continue;
			switch (region_chan->band) {
			case BAND_A:
				switch (band) {
				case BAND_A:
				case BAND_AN:
				case BAND_A | BAND_AN:
				case BAND_A | BAND_AN | BAND_AAC:
					break;
				default:
					continue;
				}
				break;
			case BAND_B:
			case BAND_G:
				switch (band) {
				case BAND_B:
				case BAND_G:
				case BAND_G | BAND_B:
				case BAND_GN:
				case BAND_G | BAND_GN:
				case BAND_B | BAND_G | BAND_GN:
				case BAND_B | BAND_G | BAND_GN | BAND_GAC:
					break;
				default:
					continue;
				}
				break;
			default:
				continue;
			}
			break;
		}

		/* Check if region channel found */
		if (j >= MAX_REGION_CHANNEL_NUM) {
			PRINTM(MERROR, "11D: region_chan not found. Band[%d]\n",
			       band);
			LEAVE();
			return MLAN_STATUS_FAILURE;
		}

		/* Generate parsed region channel info from region channel */
		memset(pmadapter, &parsed_region_chan, 0,
		       sizeof(parsed_region_chan_11d_t));
		wlan_11d_generate_parsed_region_chan(pmadapter, region_chan,
						     &parsed_region_chan);

		/* Generate domain info from parsed region channel info */
		wlan_11d_generate_domain_info(pmadapter, &parsed_region_chan);

		/* Set domain info */
		ret = wlan_11d_send_domain_info(pmpriv, MNULL);
		if (ret) {
			PRINTM(MERROR,
			       "11D: Error sending domain info to FW\n");
		}
	}

	LEAVE();
	return ret;
}
Exemplo n.º 11
0
/**
 *  @brief This function parses country info from AP and
 *           download country info to FW
 *
 *  @param pmpriv       A pointer to mlan_private structure
 *  @param pbss_desc     A pointer to BSS descriptor
 *
 *  @return             MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE
 */
mlan_status
wlan_11d_parse_dnld_countryinfo(mlan_private * pmpriv,
				BSSDescriptor_t * pbss_desc)
{
	mlan_status ret = MLAN_STATUS_SUCCESS;
	mlan_adapter *pmadapter = pmpriv->adapter;
	parsed_region_chan_11d_t region_chan;
	parsed_region_chan_11d_t bssdesc_region_chan;
	t_u32 i, j;

	ENTER();

	/* Only valid if 11D is enabled */
	if (wlan_11d_is_enabled(pmpriv)) {

		memset(pmadapter, &region_chan, 0,
		       sizeof(parsed_region_chan_11d_t));
		memset(pmadapter, &bssdesc_region_chan, 0,
		       sizeof(parsed_region_chan_11d_t));

		memcpy(pmadapter, &region_chan,
		       &pmadapter->parsed_region_chan,
		       sizeof(parsed_region_chan_11d_t));

		if (pbss_desc) {
			/* Parse domain info if available */
			ret = wlan_11d_parse_domain_info(pmadapter,
							 &pbss_desc->
							 country_info,
							 (t_u8) pbss_desc->
							 bss_band,
							 &bssdesc_region_chan);

			if (ret == MLAN_STATUS_SUCCESS) {
				/* Update the channel-power table */
				for (i = 0;
				     ((i < bssdesc_region_chan.no_of_chan)
				      && (i < MAX_NO_OF_CHAN)); i++) {

					for (j = 0;
					     ((j < region_chan.no_of_chan)
					      && (j < MAX_NO_OF_CHAN)); j++) {
						/*
						 * Channel already exists, use minimum of existing
						 * tx power and tx_power received from
						 * country info of the current AP
						 */
						if (region_chan.chan_pwr[i].
						    chan ==
						    bssdesc_region_chan.
						    chan_pwr[j].chan &&
						    region_chan.chan_pwr[i].
						    band ==
						    bssdesc_region_chan.
						    chan_pwr[j].band) {
							region_chan.chan_pwr[j].
								pwr =
								MIN(region_chan.
								    chan_pwr[j].
								    pwr,
								    bssdesc_region_chan.
								    chan_pwr[i].
								    pwr);
							break;
						}
					}
				}
			}
		}

		/* Generate domain info */
		wlan_11d_generate_domain_info(pmadapter, &region_chan);

		/* Set domain info */
		ret = wlan_11d_send_domain_info(pmpriv, MNULL);
		if (ret) {
			PRINTM(MERROR,
			       "11D: Error sending domain info to FW\n");
		}
	}

	LEAVE();
	return ret;
}
Exemplo n.º 12
0
/**
 *  @brief This function initializes proc entry
 *
 *  @param priv     A pointer to bt_private structure
 *  @param m_dev    A pointer to struct m_dev
 *  @param seq      Sequence number
 *
 *  @return	BT_STATUS_SUCCESS or BT_STATUS_FAILURE
 */
int
bt_proc_init(bt_private * priv, struct m_dev *m_dev, int seq)
{
    int ret = BT_STATUS_SUCCESS;
    struct proc_dir_entry *entry;
    int i, j;
    ENTER();

    bpriv = priv;
    memset(cmd52_string, 0, CMD52_STR_LEN);
    if (proc_mbt) {
        priv->dev_proc[seq].proc_entry =
            proc_mkdir(m_dev->name, proc_mbt);
        if (!priv->dev_proc[seq].proc_entry) {
            PRINTM(ERROR, "BT: Could not mkdir %s!\n", m_dev->name);
            ret = BT_STATUS_FAILURE;
            goto done;
        }
        priv->dev_proc[seq].pfiles =
            kmalloc(sizeof(proc_files), GFP_ATOMIC);
        if (!priv->dev_proc[seq].pfiles) {
            PRINTM(ERROR,
                   "BT: Could not alloc memory for pfile!\n");
            ret = BT_STATUS_FAILURE;
            goto done;
        }
        memcpy((u8 *) priv->dev_proc[seq].pfiles, (u8 *) proc_files,
               sizeof(proc_files));
        priv->dev_proc[seq].num_proc_files = ARRAY_SIZE(proc_files);
        for (j = 0; j < priv->dev_proc[seq].num_proc_files; j++)
            priv->dev_proc[seq].pfiles[j].pdata = NULL;
        for (j = 0; j < priv->dev_proc[seq].num_proc_files; j++) {
            priv->dev_proc[seq].pfiles[j].pdata =
                kmalloc(priv->dev_proc[seq].pfiles[j].
                        num_items * sizeof(struct item_data),
                        GFP_ATOMIC);
            if (!priv->dev_proc[seq].pfiles[j].pdata) {
                PRINTM(ERROR,
                       "BT: Could not alloc memory for pdata!\n");
                ret = BT_STATUS_FAILURE;
                goto done;
            }
            memcpy((u8 *) priv->dev_proc[seq].pfiles[j].pdata,
                   (u8 *) proc_files[j].pdata,
                   priv->dev_proc[seq].pfiles[j].num_items *
                   sizeof(struct item_data));
            for (i = 0; i < priv->dev_proc[seq].pfiles[j].num_items;
                    i++) {
                if (priv->dev_proc[seq].pfiles[j].
                        pdata[i].flag & OFFSET_BT_DEV)
                    priv->dev_proc[seq].pfiles[j].pdata[i].
                    addr =
                        priv->dev_proc[seq].pfiles[j].
                        pdata[i].offset +
                        (t_ptr) & priv->bt_dev;
                if (priv->dev_proc[seq].pfiles[j].
                        pdata[i].flag & OFFSET_BT_ADAPTER)
                    priv->dev_proc[seq].pfiles[j].pdata[i].
                    addr =
                        priv->dev_proc[seq].pfiles[j].
                        pdata[i].offset +
                        (t_ptr) priv->adapter;
            }
            priv->dev_proc[seq].pfiles[j].pbt = priv;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
            entry = proc_create_data(proc_files[j].name,
                                     S_IFREG | proc_files[j].
                                     fileflag,
                                     priv->dev_proc[seq].proc_entry,
                                     proc_files[j].fops,
                                     &priv->dev_proc[seq].
                                     pfiles[j]);
            if (entry == NULL)
#else
            entry = create_proc_entry(proc_files[j].name,
                                      S_IFREG | proc_files[j].
                                      fileflag,
                                      priv->dev_proc[seq].
                                      proc_entry);
            if (entry) {
                entry->data = &priv->dev_proc[seq].pfiles[j];
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30)
                entry->owner = THIS_MODULE;
#endif
                entry->proc_fops = proc_files[j].fops;
            } else
#endif
                PRINTM(MSG, "BT: Fail to create proc %s\n",
                       proc_files[j].name);
        }
    }
done:
    if (ret == BT_STATUS_FAILURE) {
        if (priv->dev_proc[seq].proc_entry) {
            remove_proc_entry(m_dev->name, proc_mbt);
            priv->dev_proc[seq].proc_entry = NULL;
        }
        if (priv->dev_proc[seq].pfiles) {
            for (j = 0; j < priv->dev_proc[seq].num_proc_files; j++) {
                if (priv->dev_proc[seq].pfiles[j].pdata) {
                    kfree(priv->dev_proc[seq].pfiles[j].
                          pdata);
                    priv->dev_proc[seq].pfiles[j].pdata =
                        NULL;
                }
            }
            kfree(priv->dev_proc[seq].pfiles);
            priv->dev_proc[seq].pfiles = NULL;
        }
    }
    LEAVE();
    return ret;
}
Exemplo n.º 13
0
/**
 *  @brief This function handle the generic file open
 *
 *  @param inode   A pointer to inode structure
 *  @param file    A pointer to file structure
 *  @return	BT_STATUS_SUCCESS or other error no.
 */
static int
proc_open(struct inode *inode, struct file *file)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0)
    struct proc_private_data *priv = PDE_DATA(inode);
#else
    struct proc_private_data *priv = PDE(inode)->data;
#endif
    struct proc_data *pdata;
    int i;
    char *p;
    u32 val = 0;
    ENTER();
    priv->pbt->adapter->skb_pending =
        skb_queue_len(&priv->pbt->adapter->tx_queue);
    file->private_data = kzalloc(sizeof(struct proc_data), GFP_KERNEL);
    if (file->private_data == NULL) {
        PRINTM(ERROR, "BT: Can not alloc mem for proc_data\n");
        LEAVE();
        return -ENOMEM;
    }
    pdata = (struct proc_data *)file->private_data;
    pdata->rdbuf = kmalloc(priv->bufsize, GFP_KERNEL);
    if (pdata->rdbuf == NULL) {
        PRINTM(ERROR, "BT: Can not alloc mem for rdbuf\n");
        kfree(file->private_data);
        LEAVE();
        return -ENOMEM;
    }
    if (priv->fileflag == DEFAULT_FILE_PERM) {
        pdata->wrbuf = kzalloc(priv->bufsize, GFP_KERNEL);
        if (pdata->wrbuf == NULL) {
            PRINTM(ERROR, "BT: Can not alloc mem for wrbuf\n");
            kfree(pdata->rdbuf);
            kfree(file->private_data);
            return -ENOMEM;
        }
        pdata->maxwrlen = priv->bufsize;
        pdata->on_close = proc_on_close;
    }
    p = pdata->rdbuf;
    for (i = 0; i < priv->num_items; i++) {
        if (priv->pdata[i].size == 1)
            val = *((u8 *) priv->pdata[i].addr);
        else if (priv->pdata[i].size == 2)
            val = *((u16 *) priv->pdata[i].addr);
        else if (priv->pdata[i].size == 4)
            val = *((u32 *) priv->pdata[i].addr);
        if (priv->pdata[i].flag & SHOW_INT)
            p += sprintf(p, "%s=%d\n", priv->pdata[i].name, val);
        else if (priv->pdata[i].flag & SHOW_HEX)
            p += sprintf(p, "%s=0x%x\n", priv->pdata[i].name, val);
        else if (priv->pdata[i].flag & SHOW_STRING) {
            if (!strncmp
                    (priv->pdata[i].name, "sdcmd52rw",
                     strlen("sdcmd52rw"))) {
                sd_read_cmd52_val(bpriv);
                form_cmd52_string(bpriv);
            }
            p += sprintf(p, "%s=%s\n", priv->pdata[i].name,
                         (char *)priv->pdata[i].addr);
        }
    }
    pdata->rdlen = strlen(pdata->rdbuf);
    LEAVE();
    return BT_STATUS_SUCCESS;
}
Exemplo n.º 14
0
static cairo_int_status_t _cairo_xynth_surface_composite_trapezoids (cairo_operator_t cairo_operator, cairo_pattern_t *pattern, void *abstract_surface, cairo_antialias_t antialias, int src_x, int src_y, int dst_x, int dst_y, unsigned int width, unsigned int height, cairo_trapezoid_t *traps, int num_traps)
{
	int i;
	int mask_bpp;
	int mask_stride;
	s_render_t *mask;
	unsigned char *mask_data;
	cairo_int_status_t status;
	cairo_xynth_surface_t *src;
	cairo_xynth_surface_t *dst;
	s_render_trap_t *render_traps;
	S_RENDER_FORMAT render_format;
	cairo_surface_attributes_t attributes;
	ENTER();
	dst = (cairo_xynth_surface_t *) abstract_surface;
	if (num_traps > 0) {
		render_traps = (s_render_trap_t *) malloc(sizeof(s_render_trap_t) * num_traps);
		if (render_traps == NULL) {
			LEAVE();
			status = CAIRO_STATUS_NO_MEMORY;
			goto out0;
		} 
	} else {
		num_traps = 0;
		render_traps = NULL;
	}
	for (i = 0; i < num_traps; i++) {
		render_traps[i].top = traps[i].top;
		render_traps[i].bottom = traps[i].bottom;
		render_traps[i].left1x = traps[i].left.p1.x;
		render_traps[i].left2x = traps[i].left.p2.x;
		render_traps[i].right1x = traps[i].right.p1.x;
		render_traps[i].right2x = traps[i].right.p2.x;
		render_traps[i].left1y = traps[i].left.p1.y;
		render_traps[i].left2y = traps[i].left.p2.y;
		render_traps[i].right1y = traps[i].right.p1.y;
		render_traps[i].right2y = traps[i].right.p2.y;
	}
	if (cairo_operator == CAIRO_OPERATOR_ADD &&
	    _cairo_pattern_is_opaque_solid (pattern) &&
	    dst->cairo.content == CAIRO_CONTENT_ALPHA &&
	    !dst->render->has_clip &&
	    antialias != CAIRO_ANTIALIAS_NONE) {
		s_render_add_trapezoid(dst->render, 0, 0, num_traps, render_traps);
	    	free(render_traps);
	    	return CAIRO_STATUS_SUCCESS;
	}
	status = _cairo_pattern_acquire_surface(pattern, &dst->cairo, src_x, src_y, width, height, (cairo_surface_t **) &src, &attributes);
	if (status) {
		goto out1;
	}
	status = _cairo_xynth_surface_set_attributes(src, &attributes);
	if (status) {
		goto out2;
	}
	switch (antialias) {
		case CAIRO_ANTIALIAS_NONE:
			render_format = S_RENDER_FORMAT_A1;
			mask_stride = (width + 31) / 8;
			mask_bpp = 1;
			break;
		case CAIRO_ANTIALIAS_GRAY:
		case CAIRO_ANTIALIAS_SUBPIXEL:
		case CAIRO_ANTIALIAS_DEFAULT:
		default:
			render_format = S_RENDER_FORMAT_A8;
			mask_stride = (width + 3) & ~3;
			mask_bpp = 8;
			break;
	}
	mask_data = calloc(1, mask_stride * height);
	if (!mask_data) {
		status = CAIRO_STATUS_NO_MEMORY;
		goto out3;
	}
	s_render_init_for_data(&mask, mask_data, render_format, width, height, mask_bpp, mask_stride);
	s_render_add_trapezoid(mask, - dst_x, - dst_y, num_traps, render_traps);
	s_render_composite(_cairo_xynth_operator(cairo_operator),
	                   src->render,
	                   mask,
	                   dst->render,
	                   src_x + attributes.x_offset,
	                   src_y + attributes.y_offset,
	                   0, 0,
	                   dst_x, dst_y,
	                   width, height);
	if (!_cairo_operator_bounded_by_mask(cairo_operator)) {
		status = _cairo_surface_composite_shape_fixup_unbounded(&dst->cairo,
		                                                        &attributes, src->render->width, src->render->height,
		                                                        width, height,
		                                                        src_x, src_y,
		                                                        0, 0,
		                                                        dst_x, dst_y, width, height);
	}
	s_render_uninit(mask);
out3:	free(mask_data);
out2:	_cairo_pattern_release_surface(pattern, &src->cairo, &attributes);
out1:	free(render_traps);
out0:	LEAVE();
	return 0;
}
Exemplo n.º 15
0
template <DbType T> void
gnc_dbi_session_begin (QofBackend* qbe, QofSession* session,
                             const char* book_id, gboolean ignore_lock,
                             gboolean create, gboolean force)
{
    GncDbiBackend* be = (GncDbiBackend*)qbe;
    GncDbiTestResult dbi_test_result = GNC_DBI_PASS;
    PairVec options;

    g_return_if_fail (qbe != nullptr);
    g_return_if_fail (session != nullptr);
    g_return_if_fail (book_id != nullptr);

    ENTER (" ");

    /* Split the book-id
     * Format is protocol://username:[email protected]:port/dbname
     where username, password and port are optional) */
    UriStrings uri(book_id);

    if (T == DbType::DBI_PGSQL)
    {
        if (uri.m_portnum == 0)
            uri.m_portnum = PGSQL_DEFAULT_PORT;
        /* Postgres's SQL interface coerces identifiers to lower case, but the
         * C interface is case-sensitive. This results in a mixed-case dbname
         * being created (with a lower case name) but then dbi can't conect to
         * it. To work around this, coerce the name to lowercase first. */
        auto lcname = g_utf8_strdown (uri.dbname(), -1);
        uri.m_dbname = std::string{lcname};
        g_free(lcname);
    }
    be->connect(nullptr);

    auto conn = conn_setup<T>(qbe, options, uri);
    if (conn == nullptr)
    {
        LEAVE("Error");
        return;
    }

    be->set_exists(true); //May be unset in the error handler.
    auto result = dbi_conn_connect (conn);
    if (result == 0)
    {
        if (T == DbType::DBI_MYSQL)
            adjust_sql_options (conn);
        if(!conn_test_dbi_library(conn, qbe))
        {
            dbi_conn_close(conn);
            LEAVE("Error");
            return;
        }
        if (create && !force && save_may_clobber_data (conn,
                                                       uri.quote_dbname(T)))
        {
            qof_backend_set_error (qbe, ERR_BACKEND_STORE_EXISTS);
            PWARN ("Databse already exists, Might clobber it.");
            dbi_conn_close(conn);
            LEAVE("Error");
            return;
        }

    }
    else
    {

        if (be->exists())
        {
            PERR ("Unable to connect to database '%s'\n", uri.dbname());
            qof_backend_set_error (qbe, ERR_BACKEND_SERVER_ERR);
            dbi_conn_close(conn);
            LEAVE("Error");
            return;
        }

        if (create)
        {
            if (!create_database(T, qbe, conn, uri.quote_dbname(T).c_str()))
            {
                dbi_conn_close(conn);
                LEAVE("Error");
                return;
            }
            conn = conn_setup<T>(qbe, options, uri);
            result = dbi_conn_connect (conn);
            if (result < 0)
            {
                PERR ("Unable to create database '%s'\n", uri.dbname());
                qof_backend_set_error (qbe, ERR_BACKEND_SERVER_ERR);
                dbi_conn_close(conn);
                LEAVE("Error");
                return;
            }
            if (T == DbType::DBI_MYSQL)
                adjust_sql_options (conn);
            if (!conn_test_dbi_library(conn, qbe))
            {
                if (T == DbType::DBI_PGSQL)
                    dbi_conn_select_db (conn, "template1");
                dbi_conn_queryf (conn, "DROP DATABASE %s",
                                 uri.quote_dbname(T).c_str());
                dbi_conn_close(conn);
                return;
            }
        }
        else
        {
            qof_backend_set_error (qbe, ERR_BACKEND_NO_SUCH_DB);
            qof_backend_set_message (qbe, "Database %s not found", uri.dbname());
        }
    }

    be->connect(nullptr);
    try
    {
        be->connect(new GncDbiSqlConnection(T, qbe, conn, ignore_lock));
    }
    catch (std::runtime_error& err)
    {
        return;
    }
    /* We should now have a proper session set up.
     * Let's start logging */
    auto translog_path = gnc_build_translog_path (uri.basename().c_str());
    xaccLogSetBaseName (translog_path);
    PINFO ("logpath=%s", translog_path ? translog_path : "(null)");
    g_free (translog_path);

    LEAVE (" ");
}
Exemplo n.º 16
0
/**
 *  @brief This function parses country information for region channel
 *
 *  @param pmadapter            Pointer to mlan_adapter structure
 *  @param country_info         Country information
 *  @param band                 Chan band
 *  @param parsed_region_chan   Pointer to parsed_region_chan_11d_t
 *
 *  @return                     MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE
 */
mlan_status
wlan_11d_parse_domain_info(pmlan_adapter pmadapter,
			   IEEEtypes_CountryInfoFullSet_t * country_info,
			   t_u8 band,
			   parsed_region_chan_11d_t * parsed_region_chan)
{
	t_u8 no_of_sub_band, no_of_chan;
	t_u8 last_chan, first_chan, cur_chan = 0;
	t_u8 idx = 0;
	t_u8 j, i;

	ENTER();

	/*
	 * Validation Rules:
	 *    1. Valid Region Code
	 *    2. First Chan increment
	 *    3. Channel range no overlap
	 *    4. Channel is valid?
	 *    5. Channel is supported by Region?
	 *    6. Others
	 */

	HEXDUMP("country_info", (t_u8 *) country_info, 30);

	/* Step 1: Check region_code */
	if (!(*(country_info->country_code)) ||
	    (country_info->len <= COUNTRY_CODE_LEN)) {
		/* No region info or wrong region info: treat as no 11D info */
		LEAVE();
		return MLAN_STATUS_FAILURE;
	}

	no_of_sub_band = (country_info->len - COUNTRY_CODE_LEN) /
		sizeof(IEEEtypes_SubbandSet_t);

	for (j = 0, last_chan = 0; j < no_of_sub_band; j++) {

		if (country_info->sub_band[j].first_chan <= last_chan) {
			/* Step2&3: Check First Chan Num increment and no
			   overlap */
			PRINTM(MINFO, "11D: Chan[%d>%d] Overlap\n",
			       country_info->sub_band[j].first_chan, last_chan);
			continue;
		}

		first_chan = country_info->sub_band[j].first_chan;
		no_of_chan = country_info->sub_band[j].no_of_chan;

		for (i = 0; idx < MAX_NO_OF_CHAN && i < no_of_chan; i++) {
			/* Step 4 : Channel is supported? */
			if (wlan_11d_get_chan
			    (pmadapter, band, first_chan, i,
			     &cur_chan) == MFALSE) {
				/* Chan is not found in UN table */
				PRINTM(MWARN,
				       "11D: channel is not supported: %d\n",
				       i);
				break;
			}

			last_chan = cur_chan;

			/* Step 5: We don't need to check if cur_chan is
			   supported by mrvl in region */
			parsed_region_chan->chan_pwr[idx].chan = cur_chan;
			parsed_region_chan->chan_pwr[idx].band = band;
			parsed_region_chan->chan_pwr[idx].pwr =
				country_info->sub_band[j].max_tx_pwr;
			idx++;
		}

		/* Step 6: Add other checking if any */
	}

	parsed_region_chan->no_of_chan = idx;

	PRINTM(MINFO, "11D: number of channel=0x%x\n",
	       parsed_region_chan->no_of_chan);
	HEXDUMP("11D: parsed_region_chan",
		(t_u8 *) parsed_region_chan->chan_pwr,
		sizeof(chan_power_11d_t) * idx);

	LEAVE();
	return MLAN_STATUS_SUCCESS;
}
Exemplo n.º 17
0
/**
 *  @brief This function initializes the private structure
 *  		and sets default values to the members of mlan_private.
 *
 *  @param priv    A pointer to mlan_private structure
 *
 *  @return        N/A
 */
t_void
wlan_init_priv(pmlan_private priv)
{
    int i;
    pmlan_adapter pmadapter = priv->adapter;

    ENTER();

    priv->media_connected = MFALSE;
    memset(priv->curr_addr, 0xff, MLAN_MAC_ADDR_LENGTH);

    priv->pkt_tx_ctrl = 0;
    priv->bss_mode = MLAN_BSS_MODE_INFRA;
    priv->data_rate = 0;        /* Initially indicate the rate as auto */
    priv->is_data_rate_auto = MTRUE;
    priv->bcn_avg_factor = DEFAULT_BCN_AVG_FACTOR;
    priv->data_avg_factor = DEFAULT_DATA_AVG_FACTOR;

    priv->sec_info.wep_status = Wlan802_11WEPDisabled;
    priv->sec_info.authentication_mode = MLAN_AUTH_MODE_OPEN;
    priv->sec_info.encryption_mode = MLAN_ENCRYPTION_MODE_NONE;
    for (i = 0; i < sizeof(priv->wep_key) / sizeof(priv->wep_key[0]); i++)
        memset(&priv->wep_key[i], 0, sizeof(mrvl_wep_key_t));
    priv->wep_key_curr_index = 0;
    priv->adhoc_aes_enabled = MFALSE;
    priv->gen_null_pkg = MTRUE; /* Enable NULL Pkg generation */
    priv->curr_pkt_filter = HostCmd_ACT_MAC_RX_ON |
                            HostCmd_ACT_MAC_TX_ON | HostCmd_ACT_MAC_ETHERNETII_ENABLE;

    priv->beacon_period = MLAN_BEACON_INTERVAL;
    priv->pattempted_bss_desc = MNULL;
    memset(&priv->curr_bss_params, 0, sizeof(priv->curr_bss_params));
    priv->listen_interval = MLAN_DEFAULT_LISTEN_INTERVAL;

    memset(&priv->prev_ssid, 0, sizeof(priv->prev_ssid));
    memset(&priv->prev_bssid, 0, sizeof(priv->prev_bssid));
    memset(&priv->assoc_rsp_buf, 0, sizeof(priv->assoc_rsp_buf));
    priv->assoc_rsp_size = 0;
    priv->adhoc_channel = DEFAULT_AD_HOC_CHANNEL;
    priv->atim_window = 0;
    priv->adhoc_state = ADHOC_IDLE;
    priv->tx_power_level = 0;
    priv->max_tx_power_level = 0;
    priv->min_tx_power_level = 0;
    priv->tx_rate = 0;
    priv->rxpd_htinfo = 0;
    priv->rxpd_rate = 0;
    priv->rate_bitmap = 0;
    priv->data_rssi_last = 0;
    priv->data_rssi_avg = 0;
    priv->data_nf_avg = 0;
    priv->data_nf_last = 0;
    priv->bcn_rssi_last = 0;
    priv->bcn_rssi_avg = 0;
    priv->bcn_nf_avg = 0;
    priv->bcn_nf_last = 0;
    memset(&priv->wpa_ie, 0, sizeof(priv->wpa_ie));
    memset(&priv->aes_key, 0, sizeof(priv->aes_key));
    priv->wpa_ie_len = 0;
    priv->wpa_is_gtk_set = MFALSE;
    priv->wmm_required = MTRUE;
    priv->wmm_enabled = MFALSE;
    priv->wmm_qosinfo = 0;
    priv->gen_null_pkg = MTRUE; /* Enable NULL Pkg generation */
    memset(&priv->mrvl_assoc_tlv_buf, 0, sizeof(priv->mrvl_assoc_tlv_buf));
    priv->mrvl_assoc_tlv_buf_len = 0;
    memset(&priv->wps, 0, sizeof(priv->wps));
    memset(&priv->gen_ie_buf, 0, sizeof(priv->gen_ie_buf));
    priv->gen_ie_buf_len = 0;
    memset(priv->vs_ie, 0, sizeof(priv->vs_ie));

    pmadapter->callbacks.moal_init_lock(&priv->rx_pkt_lock);
    priv->pcurr_bcn_buf = MNULL;
    priv->curr_bcn_size = 0;
    pmadapter->callbacks.moal_init_lock(&priv->curr_bcn_buf_lock);

    for (i = 0; i < MAX_NUM_TID; i++)
        priv->addba_reject[i] = ADDBA_RSP_STATUS_ACCEPT;

    util_init_list_head(&priv->tx_ba_stream_tbl_ptr, MTRUE,
                        pmadapter->callbacks.moal_init_lock);
    util_init_list_head(&priv->rx_reorder_tbl_ptr, MTRUE,
                        pmadapter->callbacks.moal_init_lock);

    LEAVE();
    return;
}
Exemplo n.º 18
0
/** 
 *  @brief This function fill the txpd for tx packet  
 *  
 *  @param priv	   A pointer to mlan_private structure
 *  @param pmbuf   A pointer to the mlan_buffer for process
 *
 *  @return 	   headptr or MNULL
 */
t_void *
wlan_ops_uap_process_txpd(IN t_void * priv, IN pmlan_buffer pmbuf)
{
    pmlan_private pmpriv = (pmlan_private) priv;
    UapTxPD *plocal_tx_pd;
    t_u8 *head_ptr = MNULL;
    ENTER();

    if (!pmbuf->data_len) {
        PRINTM(MERROR, "uAP Tx Error: Invalid packet length: %d\n",
               pmbuf->data_len);
        pmbuf->status_code = MLAN_ERROR_PKT_SIZE_INVALID;
        goto done;
    }
    if (pmbuf->data_offset < (sizeof(UapTxPD) + INTF_HEADER_LEN +
                              DMA_ALIGNMENT)) {
        PRINTM(MERROR, "not enough space for UapTxPD: len=%d, offset=%d\n",
               pmbuf->data_len, pmbuf->data_offset);
        DBG_HEXDUMP(MDAT_D, "drop pkt", pmbuf->pbuf + pmbuf->data_offset,
                    pmbuf->data_len);
        pmbuf->status_code = MLAN_ERROR_PKT_SIZE_INVALID;
        goto done;
    }

    /* head_ptr should be aligned */
    head_ptr =
        pmbuf->pbuf + pmbuf->data_offset - sizeof(UapTxPD) - INTF_HEADER_LEN;
    head_ptr = (t_u8 *) ((t_u32) head_ptr & ~((t_u32) (DMA_ALIGNMENT - 1)));

    plocal_tx_pd = (UapTxPD *) (head_ptr + INTF_HEADER_LEN);
    memset(pmpriv->adapter, plocal_tx_pd, 0, sizeof(UapTxPD));

    /* Set the BSS number to TxPD */
    plocal_tx_pd->bss_num = GET_BSS_NUM(pmpriv);
    plocal_tx_pd->bss_type = pmpriv->bss_type;

    plocal_tx_pd->tx_pkt_length = (t_u16) pmbuf->data_len;

    plocal_tx_pd->priority = (t_u8) pmbuf->priority;
    plocal_tx_pd->pkt_delay_2ms =
        wlan_wmm_compute_driver_packet_delay(pmpriv, pmbuf);

    if (plocal_tx_pd->priority < NELEMENTS(pmpriv->wmm.user_pri_pkt_tx_ctrl))
        /* 
         * Set the priority specific tx_control field, setting of 0 will
         *   cause the default value to be used later in this function
         */
        plocal_tx_pd->tx_control
            = pmpriv->wmm.user_pri_pkt_tx_ctrl[plocal_tx_pd->priority];

    /* Offset of actual data */
    plocal_tx_pd->tx_pkt_offset =
        (t_u16) ((t_u32) pmbuf->pbuf + pmbuf->data_offset -
                 (t_u32) plocal_tx_pd);

    uap_endian_convert_TxPD(plocal_tx_pd);

    /* Adjust the data offset and length to include TxPD in pmbuf */
    pmbuf->data_len += pmbuf->data_offset;
    pmbuf->data_offset = (t_u32) ((t_ptr) head_ptr - (t_ptr) pmbuf->pbuf);
    pmbuf->data_len -= pmbuf->data_offset;

  done:
    LEAVE();
    return head_ptr;
}
Exemplo n.º 19
0
/**
 *  @brief  This function downloads FW blocks to device
 *
 *  @param pmadapter	A pointer to mlan_adapter
 *  @param pmfw			A pointer to firmware image
 *
 *  @return             MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE
 */
static mlan_status
wlan_prog_fw_w_helper(IN pmlan_adapter pmadapter, IN pmlan_fw_image pmfw)
{
    mlan_status ret = MLAN_STATUS_SUCCESS;
    pmlan_callbacks pcb = &pmadapter->callbacks;
    t_u8 *firmware = pmfw->pfw_buf, *RecvBuff;
    t_u32 retries = MAX_FW_RETRY, DataLength;
    t_u32 FWSeqNum = 0, TotalBytes = 0, DnldCmd;
    FWData *fwdata = MNULL;
    FWSyncHeader SyncFWHeader;

    ENTER();

    /* Allocate memory for transmit */
    ret = pcb->moal_malloc(FW_DNLD_TX_BUF_SIZE, (t_u8 **) & fwdata);
    if ((ret != MLAN_STATUS_SUCCESS) || !fwdata) {
        PRINTM(ERROR, "Could not allocate buffer for FW download\n");
        goto fw_exit;
    }

    /* Allocate memory for receive */
    ret = pcb->moal_malloc(FW_DNLD_RX_BUF_SIZE, &RecvBuff);
    if ((ret != MLAN_STATUS_SUCCESS) || !RecvBuff) {
        PRINTM(ERROR, "Could not allocate buffer for FW download response\n");
        goto cleanup;
    }

    do {
        /* Copy the header of the firmware data to get the length */
        memcpy(&fwdata->fw_header, &firmware[TotalBytes], sizeof(FWHeader));

        DataLength = wlan_le32_to_cpu(fwdata->fw_header.data_length);
        DnldCmd = wlan_le32_to_cpu(fwdata->fw_header.dnld_cmd);
        TotalBytes += sizeof(FWHeader);

        /* Copy the firmware data */
        memcpy(fwdata->data, &firmware[TotalBytes], DataLength);
        fwdata->seq_num = wlan_cpu_to_le32(FWSeqNum);
        TotalBytes += DataLength;

        /* If the send/receive fails or CRC occurs then retry */
        while (retries) {
            mlan_buffer mbuf;
            int length = FW_DATA_XMIT_SIZE;
            retries--;

            memset(&mbuf, 0, sizeof(mlan_buffer));
            mbuf.pbuf = (t_u8 *) fwdata;
            mbuf.data_len = length;

            /* Send the firmware block */
            if ((ret = pcb->moal_write_data_sync(pmadapter->pmoal_handle,
                                                 &mbuf, MLAN_USB_EP_CMD_EVENT,
                                                 MLAN_USB_BULK_MSG_TIMEOUT)) !=
                    MLAN_STATUS_SUCCESS) {
                PRINTM(ERROR, "fw_dnld: write_data failed, ret %d\n", ret);
                continue;
            }

            memset(&mbuf, 0, sizeof(mlan_buffer));
            mbuf.pbuf = RecvBuff;
            mbuf.data_len = FW_DNLD_RX_BUF_SIZE;

            /* Receive the firmware block response */
            if ((ret = pcb->moal_read_data_sync(pmadapter->pmoal_handle,
                                                &mbuf, MLAN_USB_EP_CMD_EVENT,
                                                MLAN_USB_BULK_MSG_TIMEOUT)) !=
                    MLAN_STATUS_SUCCESS) {
                PRINTM(ERROR, "fw_dnld: read_data failed, ret %d\n", ret);
                continue;
            }

            memcpy(&SyncFWHeader, RecvBuff, sizeof(FWSyncHeader));
            endian_convert_syncfwheader(&SyncFWHeader);

            /* Check the firmware block response for CRC errors */
            if (SyncFWHeader.cmd) {
                PRINTM(ERROR, "FW received Blk with CRC error 0x%x\n",
                       SyncFWHeader.cmd);
                ret = MLAN_STATUS_FAILURE;
                continue;
            }

            retries = MAX_FW_RETRY;
            break;
        }

        FWSeqNum++;
        PRINTM(INFO, ".\n");

    } while ((DnldCmd != FW_HAS_LAST_BLOCK) && retries);

cleanup:
    PRINTM(INFO, "fw_dnld: %d bytes downloaded\n", TotalBytes);

    if (RecvBuff)
        pcb->moal_mfree(RecvBuff);
    if (fwdata)
        pcb->moal_mfree((t_u8 *) fwdata);
    if (retries) {
        ret = MLAN_STATUS_SUCCESS;
    }

fw_exit:
    LEAVE();
    return ret;
}
Exemplo n.º 20
0
/**
 *  @brief This function processes received packet and forwards it
 *  		to kernel/upper layer
 *  
 *  @param adapter   A pointer to mlan_adapter
 *  @param pmbuf     A pointer to mlan_buffer which includes the received packet
 *
 *  @return 	   MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE
 */
mlan_status
wlan_ops_uap_process_rx_packet(IN t_void * adapter, IN pmlan_buffer pmbuf)
{
    pmlan_adapter pmadapter = (pmlan_adapter) adapter;
    mlan_status ret = MLAN_STATUS_SUCCESS;
    UapRxPD *prx_pd;
    wlan_mgmt_pkt *puap_pkt_hdr = MNULL;

    RxPacketHdr_t *prx_pkt;
    pmlan_private priv = pmadapter->priv[pmbuf->bss_index];
    t_u8 ta[MLAN_MAC_ADDR_LENGTH];
    t_u16 rx_pkt_type = 0;
    sta_node *sta_ptr = MNULL;

    ENTER();

    prx_pd = (UapRxPD *) (pmbuf->pbuf + pmbuf->data_offset);
    /* Endian conversion */
    uap_endian_convert_RxPD(prx_pd);
    rx_pkt_type = prx_pd->rx_pkt_type;
    prx_pkt = (RxPacketHdr_t *) ((t_u8 *) prx_pd + prx_pd->rx_pkt_offset);

    PRINTM(MINFO, "RX Data: data_len - prx_pd->rx_pkt_offset = %d - %d = %d\n",
           pmbuf->data_len, prx_pd->rx_pkt_offset,
           pmbuf->data_len - prx_pd->rx_pkt_offset);

    if ((prx_pd->rx_pkt_offset + prx_pd->rx_pkt_length) >
        (t_u16) pmbuf->data_len) {
        PRINTM(MERROR,
               "Wrong rx packet: len=%d,rx_pkt_offset=%d,"
               " rx_pkt_length=%d\n", pmbuf->data_len, prx_pd->rx_pkt_offset,
               prx_pd->rx_pkt_length);
        pmbuf->status_code = MLAN_ERROR_PKT_SIZE_INVALID;
        ret = MLAN_STATUS_FAILURE;
        pmadapter->callbacks.moal_recv_complete(pmadapter->pmoal_handle,
                                                pmbuf, MLAN_USB_EP_DATA, ret);
        goto done;
    }
    pmbuf->data_len = prx_pd->rx_pkt_offset + prx_pd->rx_pkt_length;

    if (pmadapter->priv[pmbuf->bss_index]->mgmt_frame_passthru_mask &&
        prx_pd->rx_pkt_type == PKT_TYPE_MGMT_FRAME) {
        /* Check if this is mgmt packet and needs to forwarded to app as an
           event */
        puap_pkt_hdr =
            (wlan_mgmt_pkt *) ((t_u8 *) prx_pd + prx_pd->rx_pkt_offset);
        puap_pkt_hdr->frm_len = wlan_le16_to_cpu(puap_pkt_hdr->frm_len);
        if ((puap_pkt_hdr->wlan_header.
             frm_ctl & IEEE80211_FC_MGMT_FRAME_TYPE_MASK) == 0)
            wlan_process_802dot11_mgmt_pkt(pmadapter->priv[pmbuf->bss_index],
                                           (t_u8 *) & puap_pkt_hdr->wlan_header,
                                           puap_pkt_hdr->frm_len +
                                           sizeof(wlan_mgmt_pkt) -
                                           sizeof(puap_pkt_hdr->frm_len));
    }

    pmbuf->priority = prx_pd->priority;
    if (prx_pd->rx_pkt_type == PKT_TYPE_AMSDU) {
        pmbuf->data_len = prx_pd->rx_pkt_length;
        pmbuf->data_offset += prx_pd->rx_pkt_offset;
        wlan_11n_deaggregate_pkt(priv, pmbuf);
        goto done;
    }
    memcpy(pmadapter, ta, prx_pkt->eth803_hdr.src_addr, MLAN_MAC_ADDR_LENGTH);
    if ((rx_pkt_type != PKT_TYPE_BAR) && (prx_pd->priority < MAX_NUM_TID)) {
        if ((sta_ptr = wlan_get_station_entry(priv, ta)))
            sta_ptr->rx_seq[prx_pd->priority] = prx_pd->seq_num;
    }
    /* check if UAP enable 11n */
    if (!priv->is_11n_enabled ||
        !wlan_11n_get_rxreorder_tbl((mlan_private *) priv, prx_pd->priority,
                                    ta)) {
        if (priv->pkt_fwd)
            wlan_process_uap_rx_packet(priv, pmbuf);
        else
            wlan_upload_uap_rx_packet(pmadapter, pmbuf);
        goto done;
    }
    /* Reorder and send to OS */
    if ((ret = mlan_11n_rxreorder_pkt(priv, prx_pd->seq_num,
                                      prx_pd->priority, ta,
                                      (t_u8) prx_pd->rx_pkt_type,
                                      (void *) pmbuf))
        || (rx_pkt_type == PKT_TYPE_BAR)) {
        if ((ret =
             pmadapter->callbacks.moal_recv_complete(pmadapter->pmoal_handle,
                                                     pmbuf, MLAN_USB_EP_DATA,
                                                     ret)))
            PRINTM(MERROR, "uAP Rx Error: moal_recv_complete returned error\n");
    }
  done:
    if (priv->is_11n_enabled &&
        (pmadapter->pending_bridge_pkts >= RX_MED_THRESHOLD))
        wlan_send_delba_to_all_in_reorder_tbl(priv);
    LEAVE();
    return ret;
}
static Bool
SMI_CrtcConfigResize(ScrnInfoPtr       pScrn,
		     int               width,
		     int               height)
{
    SMIPtr pSmi = SMIPTR(pScrn);
    xf86CrtcConfigPtr crtcConf = XF86_CRTC_CONFIG_PTR(pScrn);
    int i;
    xf86CrtcPtr crtc;

    ENTER();

    /* Allocate another offscreen area and use it as screen, if it really has to be resized */
    if(!pSmi->NoAccel && pSmi->useEXA &&
       ( !pSmi->fbArea || width != pScrn->virtualX || height != pScrn->virtualY )){
	int aligned_pitch = (width*pSmi->Bpp + 15) & ~15;

	ExaOffscreenArea* fbArea = exaOffscreenAlloc(pScrn->pScreen, aligned_pitch*height, 16, TRUE, NULL, NULL);
	if(!fbArea){
	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
		   "SMI_CrtcConfigResize: Not enough memory to resize the framebuffer\n");
	    LEAVE(FALSE);
	}

	if(pSmi->fbArea)
	    exaOffscreenFree(pScrn->pScreen, pSmi->fbArea);

	pSmi->fbArea = fbArea;
	pSmi->FBOffset = fbArea->offset;
	pScrn->fbOffset = pSmi->FBOffset + pSmi->fbMapOffset;

	pScrn->pScreen->ModifyPixmapHeader(pScrn->pScreen->GetScreenPixmap(pScrn->pScreen),
					   -1,-1,-1,-1,-1, pSmi->FBBase + pSmi->FBOffset);

#if (XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(1, 9, 99, 1, 0))
	if(pScrn->pixmapPrivate.ptr)
	    /* The pixmap devPrivate just set may be overwritten by
	       xf86EnableDisableFBAccess */
	    pScrn->pixmapPrivate.ptr = pSmi->FBBase + pSmi->FBOffset;
#endif

	/* Modify the screen pitch */
	pScrn->displayWidth = aligned_pitch / pSmi->Bpp;
	pScrn->pScreen->ModifyPixmapHeader(pScrn->pScreen->GetScreenPixmap(pScrn->pScreen),
					   -1, -1, -1, -1, aligned_pitch, NULL);

	/* Modify the screen dimensions */
	pScrn->virtualX = width;
	pScrn->virtualY = height;
	pScrn->pScreen->ModifyPixmapHeader(pScrn->pScreen->GetScreenPixmap(pScrn->pScreen),
					   width, height, -1, -1, 0, NULL);
    }

    /* Setup each crtc video processor */
    for(i=0;i<crtcConf->num_crtc;i++){
	crtc = crtcConf->crtc[i];
	SMICRTC(crtc)->video_init(crtc);
	SMICRTC(crtc)->adjust_frame(crtc,crtc->x,crtc->y);
    }

    LEAVE(TRUE);
}
Exemplo n.º 22
0
/**
 *  @brief This function processes received packet and forwards it
 *  		to kernel/upper layer or send back to firmware 
 *  
 *  @param priv      A pointer to mlan_private
 *  @param pmbuf     A pointer to mlan_buffer which includes the received packet
 *
 *  @return 	   MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE
 */
mlan_status
wlan_uap_recv_packet(IN mlan_private * priv, IN pmlan_buffer pmbuf)
{
    pmlan_adapter pmadapter = priv->adapter;
    mlan_status ret = MLAN_STATUS_SUCCESS;
    RxPacketHdr_t *prx_pkt;
    pmlan_buffer newbuf = MNULL;

    ENTER();

    prx_pkt = (RxPacketHdr_t *) ((t_u8 *) pmbuf->pbuf + pmbuf->data_offset);

    DBG_HEXDUMP(MDAT_D, "uap_recv_packet", pmbuf->pbuf + pmbuf->data_offset,
                MIN(pmbuf->data_len, MAX_DATA_DUMP_LEN));

    PRINTM(MDATA, "AMSDU dest %02x:%02x:%02x:%02x:%02x:%02x\n",
           prx_pkt->eth803_hdr.dest_addr[0], prx_pkt->eth803_hdr.dest_addr[1],
           prx_pkt->eth803_hdr.dest_addr[2], prx_pkt->eth803_hdr.dest_addr[3],
           prx_pkt->eth803_hdr.dest_addr[4], prx_pkt->eth803_hdr.dest_addr[5]);

    /* don't do packet forwarding in disconnected state */
    if ((priv->media_connected == MFALSE) ||
        (pmbuf->data_len > MV_ETH_FRAME_LEN))
        goto upload;

    if (prx_pkt->eth803_hdr.dest_addr[0] & 0x01) {
        /* Multicast pkt */
        if ((newbuf =
             wlan_alloc_mlan_buffer(pmadapter, MLAN_TX_DATA_BUF_SIZE_2K, 0,
                                    MTRUE))) {
            newbuf->bss_index = pmbuf->bss_index;
            newbuf->buf_type = pmbuf->buf_type;
            newbuf->priority = pmbuf->priority;
            newbuf->in_ts_sec = pmbuf->in_ts_sec;
            newbuf->in_ts_usec = pmbuf->in_ts_usec;
            newbuf->data_offset =
                (sizeof(UapTxPD) + INTF_HEADER_LEN + DMA_ALIGNMENT);
            pmadapter->pending_bridge_pkts++;
            newbuf->flags |= MLAN_BUF_FLAG_BRIDGE_BUF;

            /* copy the data */
            memcpy(pmadapter, (t_u8 *) newbuf->pbuf + newbuf->data_offset,
                   pmbuf->pbuf + pmbuf->data_offset, pmbuf->data_len);
            newbuf->data_len = pmbuf->data_len;
            wlan_wmm_add_buf_txqueue(pmadapter, newbuf);
            if (pmadapter->pending_bridge_pkts > RX_HIGH_THRESHOLD)
                wlan_drop_tx_pkts(priv);
        }
    } else {
        if (wlan_get_station_entry(priv, prx_pkt->eth803_hdr.dest_addr)) {
            /* Intra BSS packet */
            if ((newbuf =
                 wlan_alloc_mlan_buffer(pmadapter, MLAN_TX_DATA_BUF_SIZE_2K, 0,
                                        MTRUE))) {
                newbuf->bss_index = pmbuf->bss_index;
                newbuf->buf_type = pmbuf->buf_type;
                newbuf->priority = pmbuf->priority;
                newbuf->in_ts_sec = pmbuf->in_ts_sec;
                newbuf->in_ts_usec = pmbuf->in_ts_usec;
                newbuf->data_offset =
                    (sizeof(UapTxPD) + INTF_HEADER_LEN + DMA_ALIGNMENT);
                pmadapter->pending_bridge_pkts++;
                newbuf->flags |= MLAN_BUF_FLAG_BRIDGE_BUF;

                /* copy the data */
                memcpy(pmadapter, (t_u8 *) newbuf->pbuf + newbuf->data_offset,
                       pmbuf->pbuf + pmbuf->data_offset, pmbuf->data_len);
                newbuf->data_len = pmbuf->data_len;
                wlan_wmm_add_buf_txqueue(pmadapter, newbuf);
                if (pmadapter->pending_bridge_pkts > RX_HIGH_THRESHOLD)
                    wlan_drop_tx_pkts(priv);
            }
            goto done;
        }
    }
  upload:
    /** send packet to moal */
    ret = pmadapter->callbacks.moal_recv_packet(pmadapter->pmoal_handle, pmbuf);
  done:
    LEAVE();
    return ret;
}
Exemplo n.º 23
0
/** 
 *  @brief MLAN uap ioctl handler
 *
 *  @param adapter	A pointer to mlan_adapter structure
 *  @param pioctl_req	A pointer to ioctl request buffer
 *
 *  @return		MLAN_STATUS_SUCCESS --success, otherwise fail
 */
mlan_status
mlan_uap_ioctl(t_void * adapter, pmlan_ioctl_req pioctl_req)
{
    pmlan_adapter pmadapter = (pmlan_adapter) adapter;
    mlan_status status = MLAN_STATUS_SUCCESS;
    mlan_ds_bss *bss = MNULL;
    mlan_ds_get_info *pget_info = MNULL;
    mlan_ds_misc_cfg *misc = MNULL;
    mlan_ds_sec_cfg *sec = MNULL;
    mlan_ds_pm_cfg *pm = MNULL;
    mlan_private *pmpriv = pmadapter->priv[pioctl_req->bss_num];

    ENTER();

    switch (pioctl_req->req_id) {
    case MLAN_IOCTL_BSS:
        bss = (mlan_ds_bss *) pioctl_req->pbuf;
        if (bss->sub_command == MLAN_OID_BSS_MAC_ADDR)
            status = wlan_uap_bss_ioctl_mac_address(pmadapter, pioctl_req);
        else if (bss->sub_command == MLAN_OID_BSS_STOP)
            status = wlan_uap_bss_ioctl_stop(pmadapter, pioctl_req);
        else if (bss->sub_command == MLAN_OID_BSS_START)
            status = wlan_uap_bss_ioctl_start(pmadapter, pioctl_req);
        else if (bss->sub_command == MLAN_OID_UAP_BSS_CONFIG)
            status = wlan_uap_bss_ioctl_config(pmadapter, pioctl_req);
        else if (bss->sub_command == MLAN_OID_UAP_DEAUTH_STA)
            status = wlan_uap_bss_ioctl_deauth_sta(pmadapter, pioctl_req);
        else if (bss->sub_command == MLAN_OID_UAP_BSS_RESET)
            status = wlan_uap_bss_ioctl_reset(pmadapter, pioctl_req);
        break;
    case MLAN_IOCTL_GET_INFO:
        pget_info = (mlan_ds_get_info *) pioctl_req->pbuf;
        if (pget_info->sub_command == MLAN_OID_GET_VER_EXT)
            status = wlan_uap_get_info_ver_ext(pmadapter, pioctl_req);
        else if (pget_info->sub_command == MLAN_OID_GET_DEBUG_INFO)
            status = wlan_get_info_debug_info(pmadapter, pioctl_req);
        else if (pget_info->sub_command == MLAN_OID_GET_STATS)
            status = wlan_uap_get_stats(pmadapter, pioctl_req);
        else if (pget_info->sub_command == MLAN_OID_UAP_STA_LIST)
            status = wlan_uap_get_sta_list(pmadapter, pioctl_req);
        else if (pget_info->sub_command == MLAN_OID_GET_BSS_INFO)
            status = wlan_uap_get_bss_info(pmadapter, pioctl_req);
        else if (pget_info->sub_command == MLAN_OID_GET_FW_INFO) {
            pioctl_req->data_read_written =
                sizeof(mlan_fw_info) + MLAN_SUB_COMMAND_SIZE;
            memcpy(pmadapter, &pget_info->param.fw_info.mac_addr,
                   pmpriv->curr_addr, MLAN_MAC_ADDR_LENGTH);
            pget_info->param.fw_info.fw_ver = pmadapter->fw_release_number;
        }
        break;
    case MLAN_IOCTL_MISC_CFG:
        misc = (mlan_ds_misc_cfg *) pioctl_req->pbuf;
        if (misc->sub_command == MLAN_OID_MISC_INIT_SHUTDOWN)
            status = wlan_misc_ioctl_init_shutdown(pmadapter, pioctl_req);
        if (misc->sub_command == MLAN_OID_MISC_SOFT_RESET)
            status = wlan_uap_misc_ioctl_soft_reset(pmadapter, pioctl_req);
        if (misc->sub_command == MLAN_OID_MISC_HOST_CMD)
            status = wlan_misc_ioctl_host_cmd(pmadapter, pioctl_req);
        if (misc->sub_command == MLAN_OID_MISC_GEN_IE)
            status = wlan_uap_misc_ioctl_gen_ie(pmadapter, pioctl_req);
        if (misc->sub_command == MLAN_OID_MISC_CUSTOM_IE)
            status = wlan_misc_ioctl_custom_ie_list(pmadapter, pioctl_req);
        break;
    case MLAN_IOCTL_PM_CFG:
        pm = (mlan_ds_pm_cfg *) pioctl_req->pbuf;
        if (pm->sub_command == MLAN_OID_PM_CFG_PS_MODE)
            status = wlan_uap_pm_ioctl_mode(pmadapter, pioctl_req);
        if (pm->sub_command == MLAN_OID_PM_CFG_DEEP_SLEEP)
            status = wlan_uap_pm_ioctl_deepsleep(pmadapter, pioctl_req);
        if (pm->sub_command == MLAN_OID_PM_CFG_HS_CFG) {
            status = wlan_pm_ioctl_hscfg(pmadapter, pioctl_req);
        }
        if (pm->sub_command == MLAN_OID_PM_INFO) {
            status = wlan_get_pm_info(pmadapter, pioctl_req);
        }
        break;

    case MLAN_IOCTL_SEC_CFG:
        sec = (mlan_ds_sec_cfg *) pioctl_req->pbuf;
        if (sec->sub_command == MLAN_OID_SEC_CFG_ENCRYPT_KEY)
            status = wlan_uap_sec_ioctl_set_encrypt_key(pmadapter, pioctl_req);
        if (sec->sub_command == MLAN_OID_SEC_CFG_WAPI_ENABLED)
            status = wlan_uap_sec_ioctl_wapi_enable(pmadapter, pioctl_req);
        break;
    case MLAN_IOCTL_11N_CFG:
        status = wlan_11n_cfg_ioctl(pmadapter, pioctl_req);
        break;

    default:
        break;
    }
    LEAVE();
    return status;
}
Exemplo n.º 24
0
/**
 *  @brief This function processes received packet and forwards it
 *  		to kernel/upper layer or send back to firmware 
 *  
 *  @param priv      A pointer to mlan_private
 *  @param pmbuf     A pointer to mlan_buffer which includes the received packet
 *
 *  @return 	   MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE
 */
mlan_status
wlan_process_uap_rx_packet(IN mlan_private * priv, IN pmlan_buffer pmbuf)
{
    pmlan_adapter pmadapter = priv->adapter;
    mlan_status ret = MLAN_STATUS_SUCCESS;
    UapRxPD *prx_pd;
    RxPacketHdr_t *prx_pkt;
    pmlan_buffer newbuf = MNULL;

    ENTER();

    prx_pd = (UapRxPD *) (pmbuf->pbuf + pmbuf->data_offset);
    prx_pkt = (RxPacketHdr_t *) ((t_u8 *) prx_pd + prx_pd->rx_pkt_offset);

    DBG_HEXDUMP(MDAT_D, "uAP RxPD", prx_pd,
                MIN(sizeof(UapRxPD), MAX_DATA_DUMP_LEN));
    DBG_HEXDUMP(MDAT_D, "uAP Rx Payload",
                ((t_u8 *) prx_pd + prx_pd->rx_pkt_offset),
                MIN(prx_pd->rx_pkt_length, MAX_DATA_DUMP_LEN));

    PRINTM(MINFO, "RX Data: data_len - prx_pd->rx_pkt_offset = %d - %d = %d\n",
           pmbuf->data_len, prx_pd->rx_pkt_offset,
           pmbuf->data_len - prx_pd->rx_pkt_offset);
    PRINTM(MDATA, "Rx dest %02x:%02x:%02x:%02x:%02x:%02x\n",
           prx_pkt->eth803_hdr.dest_addr[0], prx_pkt->eth803_hdr.dest_addr[1],
           prx_pkt->eth803_hdr.dest_addr[2], prx_pkt->eth803_hdr.dest_addr[3],
           prx_pkt->eth803_hdr.dest_addr[4], prx_pkt->eth803_hdr.dest_addr[5]);

    /* don't do packet forwarding in disconnected state */
    /* don't do packet forwarding when packet > 1514 */
    if ((priv->media_connected == MFALSE) ||
        ((pmbuf->data_len - prx_pd->rx_pkt_offset) > MV_ETH_FRAME_LEN))
        goto upload;

    if (prx_pkt->eth803_hdr.dest_addr[0] & 0x01) {
        /* Multicast pkt */
        if ((newbuf =
             wlan_alloc_mlan_buffer(pmadapter, MLAN_TX_DATA_BUF_SIZE_2K, 0,
                                    MTRUE))) {
            newbuf->bss_index = pmbuf->bss_index;
            newbuf->buf_type = pmbuf->buf_type;
            newbuf->priority = pmbuf->priority;
            newbuf->in_ts_sec = pmbuf->in_ts_sec;
            newbuf->in_ts_usec = pmbuf->in_ts_usec;
            newbuf->data_offset =
                (sizeof(UapTxPD) + INTF_HEADER_LEN + DMA_ALIGNMENT);
            pmadapter->pending_bridge_pkts++;
            newbuf->flags |= MLAN_BUF_FLAG_BRIDGE_BUF;

            /* copy the data, skip rxpd */
            memcpy(pmadapter, (t_u8 *) newbuf->pbuf + newbuf->data_offset,
                   pmbuf->pbuf + pmbuf->data_offset + prx_pd->rx_pkt_offset,
                   pmbuf->data_len - prx_pd->rx_pkt_offset);
            newbuf->data_len = pmbuf->data_len - prx_pd->rx_pkt_offset;
            wlan_wmm_add_buf_txqueue(pmadapter, newbuf);
            if (pmadapter->pending_bridge_pkts > RX_HIGH_THRESHOLD)
                wlan_drop_tx_pkts(priv);
        }
    } else {
        if (wlan_get_station_entry(priv, prx_pkt->eth803_hdr.dest_addr)) {
            /* Forwarding Intra-BSS packet */
            pmbuf->data_len -= prx_pd->rx_pkt_offset;
            pmbuf->data_offset += prx_pd->rx_pkt_offset;
            pmbuf->flags |= MLAN_BUF_FLAG_BRIDGE_BUF;
            pmadapter->pending_bridge_pkts++;
            wlan_wmm_add_buf_txqueue(pmadapter, pmbuf);
            if (pmadapter->pending_bridge_pkts > RX_HIGH_THRESHOLD)
                wlan_drop_tx_pkts(priv);
            pmadapter->callbacks.moal_recv_complete(pmadapter->pmoal_handle,
                                                    MNULL,
                                                    MLAN_USB_EP_DATA, ret);
            goto done;
        }
    }
  upload:
    /* Chop off RxPD */
    pmbuf->data_len -= prx_pd->rx_pkt_offset;
    pmbuf->data_offset += prx_pd->rx_pkt_offset;
    pmbuf->pparent = MNULL;

    pmadapter->callbacks.moal_get_system_time(pmadapter->pmoal_handle,
                                              &pmbuf->out_ts_sec,
                                              &pmbuf->out_ts_usec);
    PRINTM(MDATA, "%lu.%06lu : Data => kernel seq_num=%d tid=%d\n",
           pmbuf->out_ts_sec, pmbuf->out_ts_usec, prx_pd->seq_num,
           prx_pd->priority);
    ret = pmadapter->callbacks.moal_recv_packet(pmadapter->pmoal_handle, pmbuf);
    if (ret == MLAN_STATUS_FAILURE) {
        PRINTM(MERROR, "uAP Rx Error: moal_recv_packet returned error\n");
        pmbuf->status_code = MLAN_ERROR_PKT_INVALID;
    }

    if (ret != MLAN_STATUS_PENDING) {
        pmadapter->callbacks.moal_recv_complete(pmadapter->pmoal_handle, pmbuf,
                                                MLAN_USB_EP_DATA, ret);
    }
  done:
    LEAVE();
    return ret;
}
Exemplo n.º 25
0
/**
 *  @brief Aggregate multiple packets into one single AMSDU packet
 *
 *  @param priv 	A pointer to mlan_private structure
 *  @param pra_list	Pointer to the RA List table containing the pointers
 *  			    to packets.
 *  @param headroom	Any interface specific headroom that may be need. TxPD
 *  				will be formed leaving this headroom.
 *  @param ptrindex	Pointer index
 *
 *  @return		Final packet size or MLAN_STATUS_FAILURE
 */
int
wlan_11n_aggregate_pkt(mlan_private * priv, raListTbl * pra_list,
                       int headroom, int ptrindex)
{
    int pkt_size = 0;
    pmlan_adapter pmadapter = priv->adapter;
    mlan_buffer *pmbuf_aggr, *pmbuf_src;
    t_u8 *data;
    int pad = 0;
    mlan_status ret = MLAN_STATUS_SUCCESS;
#ifdef DEBUG_LEVEL1
    t_u32 sec, usec;
#endif
    mlan_tx_param tx_param;
#ifdef STA_SUPPORT
    TxPD *ptx_pd = MNULL;
#endif
    t_u32 max_amsdu_size = MIN(pra_list->max_amsdu, pmadapter->tx_buf_size);
    ENTER();

    PRINTM(MDAT_D, "Handling Aggr packet\n");

    if ((pmbuf_src =
         (pmlan_buffer) util_peek_list(pmadapter->pmoal_handle,
                                       &pra_list->buf_head, MNULL, MNULL))) {

        if (!(pmbuf_aggr = wlan_alloc_mlan_buffer(pmadapter,
                                                  pmadapter->tx_buf_size, 0,
                                                  MTRUE))) {
            PRINTM(MERROR, "Error allocating mlan_buffer\n");
            pmadapter->callbacks.moal_spin_unlock(pmadapter->pmoal_handle,
                                                  priv->wmm.ra_list_spinlock);
            LEAVE();
            return MLAN_STATUS_FAILURE;
        }

        data = pmbuf_aggr->pbuf + headroom;
        pmbuf_aggr->bss_index = pmbuf_src->bss_index;
        pmbuf_aggr->buf_type = pmbuf_src->buf_type;
        pmbuf_aggr->priority = pmbuf_src->priority;
        pmbuf_aggr->pbuf = data;
        pmbuf_aggr->data_offset = 0;

        /* Form AMSDU */
        wlan_11n_form_amsdu_txpd(priv, pmbuf_aggr);
        pkt_size = sizeof(TxPD);
#ifdef STA_SUPPORT
        if (GET_BSS_ROLE(priv) == MLAN_BSS_ROLE_STA)
            ptx_pd = (TxPD *) pmbuf_aggr->pbuf;
#endif
    } else {
        pmadapter->callbacks.moal_spin_unlock(pmadapter->pmoal_handle,
                                              priv->wmm.ra_list_spinlock);
        goto exit;
    }

    while (pmbuf_src && ((pkt_size + (pmbuf_src->data_len + LLC_SNAP_LEN)
                          + headroom) <= max_amsdu_size)) {

        pmbuf_src = (pmlan_buffer)
            util_dequeue_list(pmadapter->pmoal_handle, &pra_list->buf_head,
                              MNULL, MNULL);

        pra_list->total_pkts--;

        /* decrement for every PDU taken from the list */
        priv->wmm.pkts_queued[ptrindex]--;
        util_scalar_decrement(pmadapter->pmoal_handle,
                              &priv->wmm.tx_pkts_queued, MNULL, MNULL);

        pmadapter->callbacks.moal_spin_unlock(pmadapter->pmoal_handle,
                                              priv->wmm.ra_list_spinlock);

        pkt_size += wlan_11n_form_amsdu_pkt(pmadapter,
                                            (data + pkt_size),
                                            pmbuf_src->pbuf +
                                            pmbuf_src->data_offset,
                                            pmbuf_src->data_len, &pad);

        DBG_HEXDUMP(MDAT_D, "pmbuf_src", pmbuf_src, sizeof(mlan_buffer));
        wlan_write_data_complete(pmadapter, pmbuf_src, MLAN_STATUS_SUCCESS);

        pmadapter->callbacks.moal_spin_lock(pmadapter->pmoal_handle,
                                            priv->wmm.ra_list_spinlock);

        if (!wlan_is_ralist_valid(priv, pra_list, ptrindex)) {
            pmadapter->callbacks.moal_spin_unlock(pmadapter->pmoal_handle,
                                                  priv->wmm.ra_list_spinlock);
            LEAVE();
            return MLAN_STATUS_FAILURE;
        }

        pmbuf_src =
            (pmlan_buffer) util_peek_list(pmadapter->pmoal_handle,
                                          &pra_list->buf_head, MNULL, MNULL);
    }

    pmadapter->callbacks.moal_spin_unlock(pmadapter->pmoal_handle,
                                          priv->wmm.ra_list_spinlock);

    /* Last AMSDU packet does not need padding */
    pkt_size -= pad;
    pmbuf_aggr->data_len = pkt_size;
    wlan_11n_update_pktlen_amsdu_txpd(priv, pmbuf_aggr);
    pmbuf_aggr->data_len += headroom;
    pmbuf_aggr->pbuf = data - headroom;
    tx_param.next_pkt_len = ((pmbuf_src) ?
                             pmbuf_src->data_len + sizeof(TxPD) : 0);

    ret = wlan_sdio_host_to_card(pmadapter, MLAN_TYPE_DATA,
                                 pmbuf_aggr, &tx_param);
    switch (ret) {
    case MLAN_STATUS_RESOURCE:
        pmadapter->callbacks.moal_spin_lock(pmadapter->pmoal_handle,
                                            priv->wmm.ra_list_spinlock);

        if (!wlan_is_ralist_valid(priv, pra_list, ptrindex)) {
            pmadapter->callbacks.moal_spin_unlock(pmadapter->pmoal_handle,
                                                  priv->wmm.ra_list_spinlock);
            pmbuf_aggr->status_code = MLAN_ERROR_PKT_INVALID;
            wlan_write_data_complete(pmadapter, pmbuf_aggr,
                                     MLAN_STATUS_FAILURE);
            LEAVE();
            return MLAN_STATUS_FAILURE;
        }
#ifdef STA_SUPPORT
        /* reset tx_lock_flag */
        if ((GET_BSS_ROLE(priv) == MLAN_BSS_ROLE_STA) &&
            pmadapter->pps_uapsd_mode && (pmadapter->tx_lock_flag == MTRUE)) {
            pmadapter->tx_lock_flag = MFALSE;
            ptx_pd->flags = 0;
        }
#endif
        util_enqueue_list_head(pmadapter->pmoal_handle, &pra_list->buf_head,
                               (pmlan_linked_list) pmbuf_aggr, MNULL, MNULL);

        pra_list->total_pkts++;

        /* add back only one: aggregated packet is requeued as one */
        priv->wmm.pkts_queued[ptrindex]++;
        util_scalar_increment(pmadapter->pmoal_handle,
                              &priv->wmm.tx_pkts_queued, MNULL, MNULL);
        pmbuf_aggr->flags |= MLAN_BUF_FLAG_REQUEUED_PKT;
        pmadapter->callbacks.moal_spin_unlock(pmadapter->pmoal_handle,
                                              priv->wmm.ra_list_spinlock);
        PRINTM(MINFO, "MLAN_STATUS_RESOURCE is returned\n");
        pmbuf_aggr->status_code = MLAN_ERROR_PKT_INVALID;
        break;
    case MLAN_STATUS_FAILURE:
        pmadapter->data_sent = MFALSE;
        PRINTM(MERROR, "Error: host_to_card failed: 0x%X\n", ret);
        pmbuf_aggr->status_code = MLAN_ERROR_DATA_TX_FAIL;
        pmadapter->dbg.num_tx_host_to_card_failure++;
        wlan_write_data_complete(pmadapter, pmbuf_aggr, ret);
        goto exit;
    case MLAN_STATUS_PENDING:
        pmadapter->data_sent = MFALSE;
        break;
    case MLAN_STATUS_SUCCESS:
        wlan_write_data_complete(pmadapter, pmbuf_aggr, ret);
        break;
    default:
        break;
    }
    if (ret != MLAN_STATUS_RESOURCE) {
        pmadapter->callbacks.moal_spin_lock(pmadapter->pmoal_handle,
                                            priv->wmm.ra_list_spinlock);
        if (wlan_is_ralist_valid(priv, pra_list, ptrindex)) {
            priv->wmm.packets_out[ptrindex]++;
            priv->wmm.tid_tbl_ptr[ptrindex].ra_list_curr = pra_list;
        }
        pmadapter->bssprio_tbl[priv->bss_priority].bssprio_cur =
            pmadapter->bssprio_tbl[priv->bss_priority].bssprio_cur->pnext;
        pmadapter->callbacks.moal_spin_unlock(pmadapter->pmoal_handle,
                                              priv->wmm.ra_list_spinlock);
    }
    PRINTM_GET_SYS_TIME(MDATA, &sec, &usec);
    PRINTM_NETINTF(MDATA, priv);
    PRINTM(MDATA, "%lu.%06lu : Data => FW\n", sec, usec);

  exit:
    LEAVE();
    return (pkt_size + headroom);
}
Exemplo n.º 26
0
Arquivo: hxput.c Projeto: mischasan/hx
//--------------|---------------------------------------------
HXRET
hxput(HXFILE * hp, char const *recp, int leng)
{
    HXLOCAL loc, *locp = &loc;

    if (!hp || leng < 0 || !recp || leng > hxmaxrec(hp)
        || !(hp->mode & HX_UPDATE) || !hp->test)
        return HXERR_BAD_REQUEST;

    if (leng && !hx_test(hp, recp, leng))
        return HXERR_BAD_RECORD;

    if (SCANNING(hp) && hx_diff(hp, recp, RECDATA(_hxcurrec(hp))))
        return HXERR_BAD_REQUEST;

    ENTER(locp, hp, recp, 3);
    _hxlockset(locp, leng ? HIGH_LOCK : HEAD_LOCK);
    if (IS_MMAP(hp))
        _hxremap(locp);

    int     may_find = 1, loops = HX_MAX_CHAIN;
    int     newsize = leng ? leng + sizeof(HXREC) : 0;
    HXBUF  *currp = &locp->buf[0], *prevp = &locp->buf[1];

    // If scanning is on an overflow page, and hxdel might
    //  empty the page, hxput after hxnext can't just jump to
    //  the right page, because (prevp) is not loaded,
    //  so deleting currp would hard.
    _hxload(locp, currp, SCANNING(hp) && (leng || IS_HEAD(hp->buffer.pgno))
            ? hp->buffer.pgno : locp->head);

    while (1) {
        int     pos, hindpos, skip = 0;
        PAGENO  nextpg = currp->next;

        if (!--loops)
            LEAVE(locp, HXERR_BAD_FILE);

        // Search for the key (an old record to be deleted).
        // If SCANNING: the file is locked, and the matching
        //  record must be there.
        pos = !may_find ? -1
            : !SCANNING(hp) ? _hxfind(locp, currp, locp->hash, recp, &hindpos)
            : currp->pgno == hp->buffer.pgno ? hp->currpos : -1;

        if (pos >= 0) {
            char   *oldp = currp->data + pos;
            COUNT   oldsize = RECSIZE(oldp);
            int     delta = newsize - oldsize;

            locp->ret = RECLENG(oldp);
            may_find = 0;
            assert(!currp->delta);
            currp->delpos = pos;
            currp->delta = delta;

            if (!newsize) {     // hxdel or remove after inserted previously.

                _hxremove(currp, pos, oldsize);
                currp->recs--;
                if (SCANNING(hp))
                    hp->recsize = 0;

            } else if (FITS(hp, currp, delta, 0)) { // replace

                if (delta) {
                    memmove(oldp + newsize, oldp + oldsize,
                            currp->used - pos - oldsize);
                    currp->used += delta;
                    STSH(leng, oldp + sizeof(PAGENO));
                    if (SCANNING(hp))
                        hp->recsize = newsize;
                    DEINDEX(currp); // force indexify
                }

                memcpy(oldp + sizeof(HXREC), recp, leng);
                STAIN(currp);
                newsize = 0;

            } else if (SCANNING(hp)) {
                // At this point we are stuck: if we delete the old copy of
                // the record, we are committed to inserting the new copy
                // somewhere else, but that might require changing links
                // or even growing the file: a NO-NO during a hxnext scan.
                LEAVE(locp, HXERR_BAD_REQUEST);

            } else {            // Delete old version and continue (insert elsewhere).

                _hxremove(currp, pos, oldsize);
                currp->recs--;
            }
        }

        if (currp->used && !IS_HEAD(currp->pgno) && SHRUNK(prevp))
            skip = !_hxshift(locp, locp->head, 0, currp, prevp, NULL);

        // Insert the new record if it fits.
        if (newsize && FITS(hp, currp, newsize, 1)) {

            HXREC   hdr;

            STLG(locp->hash, &hdr.hash);
            STSH(leng, &hdr.leng);
            _hxappend(currp, (char *)&hdr, sizeof hdr);
            _hxappend(currp, recp, leng);
            currp->recs++;
            newsize = 0;
        }
        // If the current page contains only data of OTHER heads 
        // -- and hence, must be at the END of a chain --
        // unlink it from this chain. If the page is empty,
        // unlink it AND put it in the freemap.
        if (IS_HEAD(currp->pgno)) {
            skip = 0;
        } else if (!currp->used) {
            skip = 1;
            _hxputfreed(locp, currp);
            if (SCANNING(hp) && hp->buffer.pgno == currp->pgno)
                hp->buffer.used = 0;
        } else if (currp->next || !SHRUNK(currp)) {
            skip = 0;
        } else if (!skip) {     // If skip not set by _hxshift above...
            char const *rp, *ep;

            FOR_EACH_REC(rp, currp, ep)
                if (locp->head == _hxhead(locp, RECHASH(rp)))
                break;
            skip = rp == ep;    // No recs for locp->head in this tail.
        }
        if (skip)
            LINK(prevp, nextpg);
        else
            SWAP(prevp, currp);

        sync_save(locp, currp);

        if (!newsize && !prevp->next)
            break;

        if (!newsize && !may_find && !SHRUNK(prevp))
            break;

        if (prevp->next) {
            _hxload(locp, currp, prevp->next);
            continue;
        }
        // We are at the end of the chain, and rec not yet inserted.

        // Unlocking is necessary even if tail is not shared;
        //  it may be hp->tail.pgno in some other process.
        if (!FILE_HELD(hp) && !IS_HEAD(prevp->pgno))
            _hxunlock(locp, prevp->pgno, 1);

        // _hxshare/_hxfindfree may update the map (root etc).
        // Split MUST be locked before root, else risk deadlock.
        _hxlockset(locp, BOTH_LOCK);
        if (IS_MMAP(hp))
            _hxremap(locp);
        // At this point assert:
        // - head is locked, split is locked,
        // - head matches hash, npages matches filesize.
        // After locking the split, no other process can change
        // the file size.
        may_find = 0;
        COUNT   need = IS_HEAD(prevp->pgno) ? newsize : 0;

        if (!_hxshare(locp, currp, need)
            && !_hxgetfreed(locp, currp)
            && !_hxfindfree(locp, currp)) {

            // _hxgrow will zero samehead if it splits locp->head.
            PAGENO  samehead = locp->head;

            // _hxgrow will change the file length. A concurrent
            //  hxget/hxdel could miscalculate locp->head as
            //  being the newly-added page.
            _hxlock(locp, locp->npages, 0);
            _hxgrow(locp, currp, need, &samehead);
            DEBUG3("head=%u samehead=%u", locp->head, samehead);
            if (!samehead) {
                _hxputfreed(locp, currp);
                _hxpoint(locp);
                _hxload(locp, currp, locp->head);
                loops = HX_MAX_CHAIN;
                continue;
            }
        }
        // _hxgrow may clobber prevp, so we reload it. Even if
        // prevp->pgno == locp->head, prevp may contain an
        // obsolete copy of the head page. The empty page is
        // always appended to head. _hxshare only returns true
        // if currp is head and currp->next is 0, so it can't
        // clobber it. 

        _hxsave(locp, prevp);
        _hxload(locp, prevp, locp->head);
        LINK(currp, prevp->next);
        LINK(prevp, currp->pgno);
        currp->orig = DATASIZE(hp); // make SHRUNK be true
    }
/**  @brief This function handles client driver suspend
 *
 *  @param dev      A pointer to device structure
 *  @return         MLAN_STATUS_SUCCESS or error code
 */
int
woal_sdio_suspend(struct device *dev)
{
	struct sdio_func *func = dev_to_sdio_func(dev);
	mmc_pm_flag_t pm_flags = 0;
	moal_handle *handle = NULL;
	struct sdio_mmc_card *cardp;
	int i;
	int ret = MLAN_STATUS_SUCCESS;
	int hs_actived = 0;
	mlan_ds_ps_info pm_info;

	ENTER();
	PRINTM(MCMND, "<--- Enter woal_sdio_suspend --->\n");
	pm_flags = sdio_get_host_pm_caps(func);
	PRINTM(MCMND, "%s: suspend: PM flags = 0x%x\n", sdio_func_id(func),
	       pm_flags);
	if (!(pm_flags & MMC_PM_KEEP_POWER)) {
		PRINTM(MERROR,
		       "%s: cannot remain alive while host is suspended\n",
		       sdio_func_id(func));
		LEAVE();
		return -ENOSYS;
	}
	cardp = sdio_get_drvdata(func);
	if (!cardp || !cardp->handle) {
		PRINTM(MERROR, "Card or moal_handle structure is not valid\n");
		LEAVE();
		return MLAN_STATUS_SUCCESS;
	}

	handle = cardp->handle;
	if (handle->is_suspended == MTRUE) {
		PRINTM(MWARN, "Device already suspended\n");
		LEAVE();
		return MLAN_STATUS_SUCCESS;
	}
	if (handle->fw_dump) {
		PRINTM(MMSG, "suspend not allowed while FW dump!");
		ret = -EBUSY;
		goto done;
	}
	if (woal_check_driver_status(handle)) {
		PRINTM(MERROR, "Allow suspend when device is in hang state\n");
#ifdef MMC_PM_SKIP_RESUME_PROBE
		PRINTM(MCMND,
		       "suspend with MMC_PM_KEEP_POWER and MMC_PM_SKIP_RESUME_PROBE\n");
		ret = sdio_set_host_pm_flags(func,
					     MMC_PM_KEEP_POWER |
					     MMC_PM_SKIP_RESUME_PROBE);
#else
		PRINTM(MCMND, "suspend with MMC_PM_KEEP_POWER\n");
		ret = sdio_set_host_pm_flags(func, MMC_PM_KEEP_POWER);
#endif
		handle->hs_force_count++;
		handle->is_suspended = MTRUE;
		LEAVE();
		return MLAN_STATUS_SUCCESS;
	}
	handle->suspend_fail = MFALSE;
	memset(&pm_info, 0, sizeof(pm_info));
	if (MLAN_STATUS_SUCCESS ==
	    woal_get_pm_info(woal_get_priv(handle, MLAN_BSS_ROLE_ANY),
			     &pm_info)) {
		if (pm_info.is_suspend_allowed == MFALSE) {
			PRINTM(MMSG, "suspend not allowed!");
			ret = -EBUSY;
			goto done;
		}
	}
	for (i = 0; i < handle->priv_num; i++)
		netif_device_detach(handle->priv[i]->netdev);

	if (pm_keep_power) {
		/* Enable the Host Sleep */
#ifdef MMC_PM_FUNC_SUSPENDED
		handle->suspend_notify_req = MTRUE;
#endif
		hs_actived =
			woal_enable_hs(woal_get_priv
				       (handle, MLAN_BSS_ROLE_ANY));
#ifdef MMC_PM_FUNC_SUSPENDED
		handle->suspend_notify_req = MFALSE;
#endif
		if (hs_actived) {
#ifdef MMC_PM_SKIP_RESUME_PROBE
			PRINTM(MCMND,
			       "suspend with MMC_PM_KEEP_POWER and MMC_PM_SKIP_RESUME_PROBE\n");
			ret = sdio_set_host_pm_flags(func, MMC_PM_KEEP_POWER |
						     MMC_PM_SKIP_RESUME_PROBE);
#else
			PRINTM(MCMND, "suspend with MMC_PM_KEEP_POWER\n");
			ret = sdio_set_host_pm_flags(func, MMC_PM_KEEP_POWER);
#endif
		} else {
			PRINTM(MMSG, "HS not actived, suspend fail!");
			handle->suspend_fail = MTRUE;
			for (i = 0; i < handle->priv_num; i++)
				netif_device_attach(handle->priv[i]->netdev);
			ret = -EBUSY;
			goto done;
		}
	}

	/* Indicate device suspended */
	handle->is_suspended = MTRUE;
done:
	PRINTM(MCMND, "<--- Leave woal_sdio_suspend --->\n");
	LEAVE();
	return ret;
}
Exemplo n.º 28
0
template <> void
gnc_dbi_session_begin<DbType::DBI_SQLITE>(QofBackend* qbe, QofSession* session,
                               const char* book_id, gboolean ignore_lock,
                               gboolean create, gboolean force)
{
    GncDbiBackend* be = (GncDbiBackend*)qbe;
    const char* msg = nullptr;
    gboolean file_exists;
    PairVec options;

    g_return_if_fail (qbe != nullptr);
    g_return_if_fail (session != nullptr);
    g_return_if_fail (book_id != nullptr);

    ENTER (" ");

    /* Remove uri type if present */
    auto path = gnc_uri_get_path (book_id);
    std::string filepath{path};
    g_free(path);
    GFileTest ftest = static_cast<decltype (ftest)> (
        G_FILE_TEST_IS_REGULAR | G_FILE_TEST_EXISTS) ;
    file_exists = g_file_test (filepath.c_str(), ftest);
    if (!create && !file_exists)
    {
        qof_backend_set_error (qbe, ERR_FILEIO_FILE_NOT_FOUND);
        qof_backend_set_message (qbe, "Sqlite3 file %s not found",
                                 filepath.c_str());
        PWARN ("Sqlite3 file %s not found", filepath.c_str());
        LEAVE("Error");
	return;
    }

    if (create && !force && file_exists)
    {
        qof_backend_set_error (qbe, ERR_BACKEND_STORE_EXISTS);
        msg = "Might clobber, no force";
        PWARN ("%s", msg);
        LEAVE("Error");
	return;
    }

    be->connect(nullptr);
    /* dbi-sqlite3 documentation says that sqlite3 doesn't take a "host" option */
    options.push_back(std::make_pair("host", "localhost"));
    auto dirname = g_path_get_dirname (filepath.c_str());
    auto basename = g_path_get_basename (filepath.c_str());
    options.push_back(std::make_pair("dbname", basename));
    options.push_back(std::make_pair("sqlite3_dbdir", dirname));
    if (basename != nullptr) g_free (basename);
    if (dirname != nullptr) g_free (dirname);
    UriStrings uri;
    auto conn = conn_setup<DbType::DBI_SQLITE>(qbe, options, uri);
    if (conn == nullptr)
    {
        LEAVE("Error");
        return;
    }

    auto result = dbi_conn_connect (conn);

    if (result < 0)
    {
        dbi_conn_close(conn);
        PERR ("Unable to connect to %s: %d\n", book_id, result);
        qof_backend_set_error (qbe, ERR_BACKEND_BAD_URL);
        LEAVE("Error");
	return;
    }

    if (!conn_test_dbi_library(conn, qbe))
    {
        if (create && !file_exists)
        {
         /* File didn't exist before, but it does now, and we don't want to
          * leave it lying around.
          */
            dbi_conn_close (conn);
            conn = nullptr;
            g_unlink (filepath.c_str());
        }
        dbi_conn_close(conn);
        LEAVE("Bad DBI Library");
        return;
    }

    try
    {
        be->connect(new GncDbiSqlConnection(DbType::DBI_SQLITE,
                                            qbe, conn, ignore_lock));
    }
    catch (std::runtime_error& err)
    {
        return;
    }

    /* We should now have a proper session set up.
     * Let's start logging */
    xaccLogSetBaseName (filepath.c_str());
    PINFO ("logpath=%s", filepath.c_str() ? filepath.c_str() : "(null)");

    LEAVE ("");
}
/**
 *  @brief This function tells firmware to send a NULL data packet.
 *
 *  @param priv     A pointer to mlan_private structure
 *  @param flags    Transmit Pkt Flags
 *
 *  @return 	    MLAN_STATUS_SUCCESS/MLAN_STATUS_PENDING --success, otherwise failure
 */
mlan_status
wlan_send_null_packet(pmlan_private priv, t_u8 flags)
{
	pmlan_adapter pmadapter = priv->adapter;
	TxPD *ptx_pd;
/* sizeof(TxPD) + Interface specific header */
#define NULL_PACKET_HDR 256
	t_u32 data_len = NULL_PACKET_HDR;
	pmlan_buffer pmbuf = MNULL;
	t_u8 *ptr;
	mlan_status ret = MLAN_STATUS_SUCCESS;
#ifdef DEBUG_LEVEL1
	t_u32 sec, usec;
#endif

	ENTER();

	if (pmadapter->surprise_removed == MTRUE) {
		ret = MLAN_STATUS_FAILURE;
		goto done;
	}

	if (priv->media_connected == MFALSE) {
		ret = MLAN_STATUS_FAILURE;
		goto done;
	}

	if (pmadapter->data_sent == MTRUE) {
		ret = MLAN_STATUS_FAILURE;
		goto done;
	}

	pmbuf = wlan_alloc_mlan_buffer(pmadapter, data_len, 0,
				       MOAL_MALLOC_BUFFER);
	if (!pmbuf) {
		ret = MLAN_STATUS_FAILURE;
		goto done;
	}
	memset(pmadapter, pmbuf->pbuf, 0, data_len);
	pmbuf->bss_index = priv->bss_index;
	pmbuf->buf_type = MLAN_BUF_TYPE_DATA;
	ptr = pmbuf->pbuf + pmbuf->data_offset;
	pmbuf->data_len = sizeof(TxPD) + INTF_HEADER_LEN;
	ptx_pd = (TxPD *) (ptr + INTF_HEADER_LEN);
	ptx_pd->tx_control = priv->pkt_tx_ctrl;
	ptx_pd->flags = flags;
	ptx_pd->priority = WMM_HIGHEST_PRIORITY;
	ptx_pd->tx_pkt_offset = sizeof(TxPD);
	/* Set the BSS number to TxPD */
	ptx_pd->bss_num = GET_BSS_NUM(priv);
	ptx_pd->bss_type = priv->bss_type;

	endian_convert_TxPD(ptx_pd);

	ret = wlan_sdio_host_to_card(pmadapter, MLAN_TYPE_DATA, pmbuf, MNULL);

	switch (ret) {
	case MLAN_STATUS_RESOURCE:
		wlan_free_mlan_buffer(pmadapter, pmbuf);
		PRINTM(MERROR, "STA Tx Error: Failed to send NULL packet!\n");
		pmadapter->dbg.num_tx_host_to_card_failure++;
		goto done;
	case MLAN_STATUS_FAILURE:
		pmadapter->data_sent = MFALSE;
		wlan_free_mlan_buffer(pmadapter, pmbuf);
		PRINTM(MERROR, "STA Tx Error: Failed to send NULL packet!\n");
		pmadapter->dbg.num_tx_host_to_card_failure++;
		goto done;
	case MLAN_STATUS_SUCCESS:
		wlan_free_mlan_buffer(pmadapter, pmbuf);
		PRINTM(MINFO, "STA Tx: Successfully send the NULL packet\n");
		pmadapter->tx_lock_flag = MTRUE;
		break;
	case MLAN_STATUS_PENDING:
		pmadapter->data_sent = MFALSE;
		pmadapter->tx_lock_flag = MTRUE;
		break;
	default:
		break;
	}

	PRINTM_GET_SYS_TIME(MDATA, &sec, &usec);
	PRINTM_NETINTF(MDATA, priv);
	PRINTM(MDATA, "%lu.%06lu : Null data => FW\n", sec, usec);
	DBG_HEXDUMP(MDAT_D, "Null data", ptr, sizeof(TxPD) + INTF_HEADER_LEN);
done:
	LEAVE();
	return ret;
}
Exemplo n.º 30
0
static void _cairo_xynth_surface_release_dest_image (void *abstract_surface, cairo_rectangle_int16_t *interest_rect, cairo_image_surface_t *image, cairo_rectangle_int16_t *image_rect, void *image_extra)
{
	ENTER();
	NIY();
	LEAVE();
}