示例#1
0
static s32
brcmf_fil_cmd_data(struct brcmf_if *ifp, u32 cmd, void *data, u32 len, bool set)
{
	struct brcmf_pub *drvr = ifp->drvr;
	s32 err;

	if (drvr->bus_if->state != BRCMF_BUS_DATA) {
		brcmf_err("bus is down. we have nothing to do.\n");
		return -EIO;
	}

	if (data != NULL)
		len = min_t(uint, len, BRCMF_DCMD_MAXLEN);
	if (set)
		err = brcmf_proto_cdc_set_dcmd(drvr, ifp->idx, cmd, data, len);
	else
		err = brcmf_proto_cdc_query_dcmd(drvr, ifp->idx, cmd, data,
						 len);

	if (err >= 0)
		err = 0;
	else
		brcmf_err("Failed err=%d\n", err);

	return err;
}
int brcmf_c_preinit_dcmds(struct brcmf_pub *drvr)
{
	char iovbuf[BRCMF_EVENTING_MASK_LEN + 12];	/*  Room for
				 "event_msgs" + '\0' + bitvec  */
	uint up = 0;
	char buf[128], *ptr;
	u32 dongle_align = drvr->bus_if->align;
	u32 glom = 0;
	u32 roaming = 1;
	uint bcn_timeout = 3;
	int scan_assoc_time = 40;
	int scan_unassoc_time = 40;
	int i;

	mutex_lock(&drvr->proto_block);

	/* Set Country code */
	if (drvr->country_code[0] != 0) {
		if (brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_COUNTRY,
					      drvr->country_code,
					      sizeof(drvr->country_code)) < 0)
			brcmf_dbg(ERROR, "country code setting failed\n");
	}

	/* query for 'ver' to get version info from firmware */
	memset(buf, 0, sizeof(buf));
	ptr = buf;
	brcmf_c_mkiovar("ver", NULL, 0, buf, sizeof(buf));
	brcmf_proto_cdc_query_dcmd(drvr, 0, BRCMF_C_GET_VAR, buf, sizeof(buf));
	strsep(&ptr, "\n");
	/* Print fw version info */
	brcmf_dbg(ERROR, "Firmware version = %s\n", buf);

	/* Match Host and Dongle rx alignment */
	brcmf_c_mkiovar("bus:txglomalign", (char *)&dongle_align, 4, iovbuf,
		    sizeof(iovbuf));
	brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, iovbuf,
				  sizeof(iovbuf));

	/* disable glom option per default */
	brcmf_c_mkiovar("bus:txglom", (char *)&glom, 4, iovbuf, sizeof(iovbuf));
	brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, iovbuf,
				  sizeof(iovbuf));

	/* Setup timeout if Beacons are lost and roam is off to report
		 link down */
	brcmf_c_mkiovar("bcn_timeout", (char *)&bcn_timeout, 4, iovbuf,
		    sizeof(iovbuf));
	brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, iovbuf,
				  sizeof(iovbuf));

	/* Enable/Disable build-in roaming to allowed ext supplicant to take
		 of romaing */
	brcmf_c_mkiovar("roam_off", (char *)&roaming, 4,
		      iovbuf, sizeof(iovbuf));
	brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, iovbuf,
				  sizeof(iovbuf));

	/* Force STA UP */
	brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_UP, (char *)&up, sizeof(up));

	/* Setup event_msgs */
	brcmf_c_mkiovar("event_msgs", drvr->eventmask, BRCMF_EVENTING_MASK_LEN,
		      iovbuf, sizeof(iovbuf));
	brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, iovbuf,
				  sizeof(iovbuf));

	brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_SCAN_CHANNEL_TIME,
			 (char *)&scan_assoc_time, sizeof(scan_assoc_time));
	brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_SCAN_UNASSOC_TIME,
			 (char *)&scan_unassoc_time, sizeof(scan_unassoc_time));

	/* Set and enable ARP offload feature */
	brcmf_c_arp_offload_set(drvr, BRCMF_ARPOL_MODE);
	brcmf_c_arp_offload_enable(drvr, true);

	/* Set up pkt filter */
	for (i = 0; i < drvr->pktfilter_count; i++) {
		brcmf_c_pktfilter_offload_set(drvr, drvr->pktfilter[i]);
		brcmf_c_pktfilter_offload_enable(drvr, drvr->pktfilter[i],
						 0, true);
	}

	mutex_unlock(&drvr->proto_block);

	return 0;
}
示例#3
0
int brcmf_c_preinit_dcmds(struct brcmf_pub *drvr)
{
	char iovbuf[BRCMF_EVENTING_MASK_LEN + 12];	
	uint up = 0;
	char buf[128], *ptr;
	u32 dongle_align = drvr->bus_if->align;
	u32 glom = 0;
	__le32 roaming_le = cpu_to_le32(1);
	__le32 bcn_timeout_le = cpu_to_le32(3);
	__le32 scan_assoc_time_le = cpu_to_le32(40);
	__le32 scan_unassoc_time_le = cpu_to_le32(40);
	int i;

	mutex_lock(&drvr->proto_block);

	
	if (drvr->country_code[0] != 0) {
		if (brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_COUNTRY,
					      drvr->country_code,
					      sizeof(drvr->country_code)) < 0)
			brcmf_dbg(ERROR, "country code setting failed\n");
	}

	
	memset(buf, 0, sizeof(buf));
	ptr = buf;
	brcmf_c_mkiovar("ver", NULL, 0, buf, sizeof(buf));
	brcmf_proto_cdc_query_dcmd(drvr, 0, BRCMF_C_GET_VAR, buf, sizeof(buf));
	strsep(&ptr, "\n");
	
	brcmf_dbg(ERROR, "Firmware version = %s\n", buf);

	
	brcmf_c_mkiovar("bus:txglomalign", (char *)&dongle_align, 4, iovbuf,
		    sizeof(iovbuf));
	brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, iovbuf,
				  sizeof(iovbuf));

	
	brcmf_c_mkiovar("bus:txglom", (char *)&glom, 4, iovbuf, sizeof(iovbuf));
	brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, iovbuf,
				  sizeof(iovbuf));

	brcmf_c_mkiovar("bcn_timeout", (char *)&bcn_timeout_le, 4, iovbuf,
		    sizeof(iovbuf));
	brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, iovbuf,
				  sizeof(iovbuf));

/* Enable/Disable build-in roaming to allowed ext supplicant to take
 		 of romaing */				  
	brcmf_c_mkiovar("roam_off", (char *)&roaming_le, 4,
		      iovbuf, sizeof(iovbuf));
	brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, iovbuf,
				  sizeof(iovbuf));

	
	brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_UP, (char *)&up, sizeof(up));

	
	brcmf_c_mkiovar("event_msgs", drvr->eventmask, BRCMF_EVENTING_MASK_LEN,
		      iovbuf, sizeof(iovbuf));
	brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, iovbuf,
				  sizeof(iovbuf));

	brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_SCAN_CHANNEL_TIME,
		 (char *)&scan_assoc_time_le, sizeof(scan_assoc_time_le));
	brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_SCAN_UNASSOC_TIME,
		 (char *)&scan_unassoc_time_le, sizeof(scan_unassoc_time_le));

	
	brcmf_c_arp_offload_set(drvr, BRCMF_ARPOL_MODE);
	brcmf_c_arp_offload_enable(drvr, true);

	
	for (i = 0; i < drvr->pktfilter_count; i++) {
		brcmf_c_pktfilter_offload_set(drvr, drvr->pktfilter[i]);
		brcmf_c_pktfilter_offload_enable(drvr, drvr->pktfilter[i],
						 0, true);
	}

	mutex_unlock(&drvr->proto_block);

	return 0;
}