static int wlan_ret_802_11_eeprom_access(wlan_private * priv, struct cmd_ds_command *resp) { wlan_adapter *adapter = priv->adapter; struct wlan_ioctl_regrdwr *pbuf; pbuf = (struct wlan_ioctl_regrdwr *) adapter->prdeeprom; lbs_deb_enter_args(LBS_DEB_CMD, "len %d", le16_to_cpu(resp->params.rdeeprom.bytecount)); if (pbuf->NOB < le16_to_cpu(resp->params.rdeeprom.bytecount)) { pbuf->NOB = 0; lbs_deb_cmd("EEPROM read length too big\n"); return -1; } pbuf->NOB = le16_to_cpu(resp->params.rdeeprom.bytecount); if (pbuf->NOB > 0) { memcpy(&pbuf->value, (u8 *) & resp->params.rdeeprom.value, le16_to_cpu(resp->params.rdeeprom.bytecount)); lbs_deb_hex(LBS_DEB_CMD, "EEPROM", (char *)&pbuf->value, le16_to_cpu(resp->params.rdeeprom.bytecount)); } lbs_deb_leave(LBS_DEB_CMD); return 0; }
/** * lbs_cmd_fwt_access - Access the mesh forwarding table * * @priv: A pointer to &struct lbs_private structure * @cmd_action: The forwarding table action to perform * @cmd: The pre-filled FWT_ACCESS command * * returns: 0 on success and 'cmd' will be filled with the * firmware's response */ int lbs_cmd_fwt_access(struct lbs_private *priv, u16 cmd_action, struct cmd_ds_fwt_access *cmd) { int ret; lbs_deb_enter_args(LBS_DEB_CMD, "action %d", cmd_action); cmd->hdr.command = cpu_to_le16(CMD_FWT_ACCESS); cmd->hdr.size = cpu_to_le16(sizeof(struct cmd_ds_fwt_access)); cmd->hdr.result = 0; cmd->action = cpu_to_le16(cmd_action); ret = lbs_cmd_with_response(priv, CMD_FWT_ACCESS, cmd); lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); return 0; }
static int lbs_mesh_access(struct lbs_private *priv, uint16_t cmd_action, struct cmd_ds_mesh_access *cmd) { int ret; lbs_deb_enter_args(LBS_DEB_CMD, "action %d", cmd_action); cmd->hdr.command = cpu_to_le16(CMD_MESH_ACCESS); cmd->hdr.size = cpu_to_le16(sizeof(*cmd)); cmd->hdr.result = 0; cmd->action = cpu_to_le16(cmd_action); ret = lbs_cmd_with_response(priv, CMD_MESH_ACCESS, cmd); lbs_deb_leave(LBS_DEB_CMD); return ret; }
static int lbs_cfg_set_channel(struct wiphy *wiphy, struct ieee80211_channel *chan, enum nl80211_channel_type channel_type) { struct lbs_private *priv = wiphy_priv(wiphy); int ret = -ENOTSUPP; lbs_deb_enter_args(LBS_DEB_CFG80211, "freq %d, type %d", chan->center_freq, channel_type); if (channel_type != NL80211_CHAN_NO_HT) goto out; ret = lbs_set_channel(priv, chan->hw_value); out: lbs_deb_leave_args(LBS_DEB_CFG80211, "ret %d", ret); return ret; }
int lbs_cmd_fwt_access(struct cmd_ds_command *cmd, u16 cmd_action, void *pdata_buf) { struct cmd_ds_fwt_access *fwt_access = &cmd->params.fwt; lbs_deb_enter_args(LBS_DEB_CMD, "action %d", cmd_action); cmd->command = cpu_to_le16(CMD_FWT_ACCESS); cmd->size = cpu_to_le16(sizeof(struct cmd_ds_fwt_access) + sizeof(struct cmd_header)); cmd->result = 0; if (pdata_buf) memcpy(fwt_access, pdata_buf, sizeof(*fwt_access)); else memset(fwt_access, 0, sizeof(*fwt_access)); fwt_access->action = cpu_to_le16(cmd_action); lbs_deb_leave(LBS_DEB_CMD); return 0; }
static int wlan_cmd_mesh_access(wlan_private * priv, struct cmd_ds_command *cmd, u16 cmd_action, void *pdata_buf) { struct cmd_ds_mesh_access *mesh_access = &cmd->params.mesh; lbs_deb_enter_args(LBS_DEB_CMD, "action %d", cmd_action); cmd->command = cpu_to_le16(CMD_MESH_ACCESS); cmd->size = cpu_to_le16(sizeof(struct cmd_ds_mesh_access) + S_DS_GEN); cmd->result = 0; if (pdata_buf) memcpy(mesh_access, pdata_buf, sizeof(*mesh_access)); else memset(mesh_access, 0, sizeof(*mesh_access)); mesh_access->action = cpu_to_le16(cmd_action); lbs_deb_leave(LBS_DEB_CMD); return 0; }
int lbs_cmd_bt_access(struct cmd_ds_command *cmd, u16 cmd_action, void *pdata_buf) { struct cmd_ds_bt_access *bt_access = &cmd->params.bt; lbs_deb_enter_args(LBS_DEB_CMD, "action %d", cmd_action); cmd->command = cpu_to_le16(CMD_BT_ACCESS); cmd->size = cpu_to_le16(sizeof(struct cmd_ds_bt_access) + sizeof(struct cmd_header)); cmd->result = 0; bt_access->action = cpu_to_le16(cmd_action); switch (cmd_action) { case CMD_ACT_BT_ACCESS_ADD: memcpy(bt_access->addr1, pdata_buf, 2 * ETH_ALEN); lbs_deb_hex(LBS_DEB_MESH, "BT_ADD: blinded MAC addr", bt_access->addr1, 6); break; case CMD_ACT_BT_ACCESS_DEL: memcpy(bt_access->addr1, pdata_buf, 1 * ETH_ALEN); lbs_deb_hex(LBS_DEB_MESH, "BT_DEL: blinded MAC addr", bt_access->addr1, 6); break; case CMD_ACT_BT_ACCESS_LIST: bt_access->id = cpu_to_le32(*(u32 *) pdata_buf); break; case CMD_ACT_BT_ACCESS_RESET: break; case CMD_ACT_BT_ACCESS_SET_INVERT: bt_access->id = cpu_to_le32(*(u32 *) pdata_buf); break; case CMD_ACT_BT_ACCESS_GET_INVERT: break; default: break; } lbs_deb_leave(LBS_DEB_CMD); return 0; }
static int libertas_ethtool_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, u8 * bytes) { wlan_private *priv = (wlan_private *) dev->priv; wlan_adapter *adapter = priv->adapter; struct wlan_ioctl_regrdwr regctrl; char *ptr; int ret; regctrl.action = 0; regctrl.offset = eeprom->offset; regctrl.NOB = eeprom->len; if (eeprom->offset + eeprom->len > LIBERTAS_EEPROM_LEN) return -EINVAL; // mutex_lock(&priv->mutex); adapter->prdeeprom = kmalloc(eeprom->len+sizeof(regctrl), GFP_KERNEL); if (!adapter->prdeeprom) return -ENOMEM; memcpy(adapter->prdeeprom, ®ctrl, sizeof(regctrl)); /* +14 is for action, offset, and NOB in * response */ lbs_deb_ethtool("action:%d offset: %x NOB: %02x\n", regctrl.action, regctrl.offset, regctrl.NOB); ret = libertas_prepare_and_send_command(priv, CMD_802_11_EEPROM_ACCESS, regctrl.action, CMD_OPTION_WAITFORRSP, 0, ®ctrl); if (ret) { if (adapter->prdeeprom) kfree(adapter->prdeeprom); goto done; } mdelay(10); ptr = (char *)adapter->prdeeprom; /* skip the command header, but include the "value" u32 variable */ ptr = ptr + sizeof(struct wlan_ioctl_regrdwr) - 4; /* * Return the result back to the user */ memcpy(bytes, ptr, eeprom->len); if (adapter->prdeeprom) kfree(adapter->prdeeprom); // mutex_unlock(&priv->mutex); ret = 0; done: lbs_deb_enter_args(LBS_DEB_ETHTOOL, "ret %d", ret); return ret; }
static int wlan_ret_get_hw_spec(wlan_private * priv, struct cmd_ds_command *resp) { u32 i; struct cmd_ds_get_hw_spec *hwspec = &resp->params.hwspec; wlan_adapter *adapter = priv->adapter; int ret = 0; DECLARE_MAC_BUF(mac); lbs_deb_enter(LBS_DEB_CMD); adapter->fwcapinfo = le32_to_cpu(hwspec->fwcapinfo); memcpy(adapter->fwreleasenumber, hwspec->fwreleasenumber, 4); lbs_deb_cmd("GET_HW_SPEC: firmware release %u.%u.%up%u\n", adapter->fwreleasenumber[2], adapter->fwreleasenumber[1], adapter->fwreleasenumber[0], adapter->fwreleasenumber[3]); lbs_deb_cmd("GET_HW_SPEC: MAC addr %s\n", print_mac(mac, hwspec->permanentaddr)); lbs_deb_cmd("GET_HW_SPEC: hardware interface 0x%x, hardware spec 0x%04x\n", hwspec->hwifversion, hwspec->version); /* Clamp region code to 8-bit since FW spec indicates that it should * only ever be 8-bit, even though the field size is 16-bit. Some firmware * returns non-zero high 8 bits here. */ adapter->regioncode = le16_to_cpu(hwspec->regioncode) & 0xFF; for (i = 0; i < MRVDRV_MAX_REGION_CODE; i++) { /* use the region code to search for the index */ if (adapter->regioncode == libertas_region_code_to_index[i]) { break; } } /* if it's unidentified region code, use the default (USA) */ if (i >= MRVDRV_MAX_REGION_CODE) { adapter->regioncode = 0x10; lbs_pr_info("unidentified region code; using the default (USA)\n"); } if (adapter->current_addr[0] == 0xff) memmove(adapter->current_addr, hwspec->permanentaddr, ETH_ALEN); memcpy(priv->dev->dev_addr, adapter->current_addr, ETH_ALEN); if (priv->mesh_dev) memcpy(priv->mesh_dev->dev_addr, adapter->current_addr, ETH_ALEN); if (libertas_set_regiontable(priv, adapter->regioncode, 0)) { ret = -1; goto done; } if (libertas_set_universaltable(priv, 0)) { ret = -1; goto done; } done: lbs_deb_enter_args(LBS_DEB_CMD, "ret %d", ret); return ret; }