return 0;
}
-static struct host_if_drv *get_handler_from_id(int id)
+/* The u8IfIdx starts from 0 to NUM_CONCURRENT_IFC -1, but 0 index used as
+ * special purpose in wilc device, so we add 1 to the index to starts from 1.
+ * As a result, the returned index will be 1 to NUM_CONCURRENT_IFC.
+ */
+static int wilc_get_vif_idx(struct wilc_vif *vif)
{
- if (id <= 0 || id >= ARRAY_SIZE(wfidrv_list))
+ return vif->u8IfIdx + 1;
+}
+
+/* We need to minus 1 from idx which is from wilc device to get real index
+ * of wilc->vif[], because we add 1 when pass to wilc device in the function
+ * wilc_get_vif_idx.
+ * As a result, the index should be between 0 and NUM_CONCURRENT_IFC -1.
+ */
+static struct wilc_vif *wilc_get_vif_from_idx(struct wilc *wilc, int idx)
+{
+ int index = idx - 1;
+
+ if (index < 0 || index >= NUM_CONCURRENT_IFC)
return NULL;
- return wfidrv_list[id];
+
+ return wilc->vif[index];
}
static s32 handle_set_channel(struct wilc_vif *vif,
PRINT_D(HOSTINF_DBG, "Setting channel\n");
result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
if (result) {
PRINT_ER("Failed to set channel\n");
wid.size = sizeof(u32);
result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
if ((hif_op_mode->mode) == IDLE_MODE)
up(&hif_sema_driver);
wid.size = IP_ALEN;
result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
host_int_get_ipaddress(vif, hif_drv, firmware_ip_addr, idx);
wid.size = IP_ALEN;
result = wilc_send_config_pkt(hif_drv->wilc, GET_CFG, &wid, 1,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
PRINT_INFO(HOSTINF_DBG, "%pI4\n", wid.val);
PRINT_D(GENERIC_DBG, "mac addr = :%pM\n", wid.val);
result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
if (result) {
PRINT_ER("Failed to set mac address\n");
result = -EFAULT;
wid.size = ETH_ALEN;
result = wilc_send_config_pkt(hif_drv->wilc, GET_CFG, &wid, 1,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
if (result) {
PRINT_ER("Failed to get mac address\n");
}
result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, wid_list,
- wid_cnt, get_id_from_handler(hif_drv));
+ wid_cnt, wilc_get_vif_idx(vif));
if (result)
PRINT_ER("Error in setting CFG params\n");
result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, strWIDList,
u32WidsCount,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
if (result)
PRINT_ER("Failed to send scan paramters config packet\n");
wid.size = sizeof(char);
result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
if (result) {
PRINT_ER("Failed to set abort running scan\n");
result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, strWIDList,
u32WidsCount,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
if (result) {
PRINT_ER("failed to send config packet\n");
result = -EFAULT;
PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
if (result)
PRINT_ER("Failed to send dissconect config packet\n");
result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG,
strWIDList, 4,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
kfree(pu8keybuf);
} else if (pstrHostIFkeyAttr->action & ADDKEY) {
PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG,
&wid, 1,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
kfree(pu8keybuf);
} else if (pstrHostIFkeyAttr->action & REMOVEKEY) {
PRINT_D(HOSTINF_DBG, "Removing key\n");
result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG,
&wid, 1,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
} else {
wid.id = (u16)WID_KEY_ID;
wid.type = WID_CHAR;
result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG,
&wid, 1,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
}
up(&hif_drv->sem_test_key_block);
break;
result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG,
strWIDList, 2,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
kfree(pu8keybuf);
up(&hif_drv->sem_test_key_block);
result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG,
&wid, 1,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
kfree(pu8keybuf);
up(&hif_drv->sem_test_key_block);
result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG,
strWIDList, 2,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
kfree(pu8keybuf);
up(&hif_drv->sem_test_key_block);
} else if (pstrHostIFkeyAttr->action & ADDKEY) {
result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG,
&wid, 1,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
kfree(pu8keybuf);
up(&hif_drv->sem_test_key_block);
}
wid.size = (pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1;
result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
kfree(pu8keybuf);
break;
eth_zero_addr(wilc_connected_ssid);
result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
if (result) {
PRINT_ER("Failed to send dissconect config packet\n");
PRINT_D(HOSTINF_DBG, "Getting channel value\n");
result = wilc_send_config_pkt(hif_drv->wilc, GET_CFG, &wid, 1,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
if (result) {
PRINT_ER("Failed to get channel number\n");
PRINT_D(HOSTINF_DBG, "Getting RSSI value\n");
result = wilc_send_config_pkt(vif->hif_drv->wilc, GET_CFG, &wid, 1,
- get_id_from_handler(vif->hif_drv));
+ wilc_get_vif_idx(vif));
if (result) {
PRINT_ER("Failed to get RSSI value\n");
result = -EFAULT;
PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n");
result = wilc_send_config_pkt(hif_drv->wilc, GET_CFG, &wid, 1,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
if (result) {
PRINT_ER("Failed to get LINKSPEED value\n");
result = -EFAULT;
result = wilc_send_config_pkt(hif_drv->wilc, GET_CFG, strWIDList,
u32WidsCount,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
if (result)
PRINT_ER("Failed to send scan paramters config packet\n");
PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
if (result) {
PRINT_ER("Failed to SET incative time\n");
wid.size = sizeof(u32);
result = wilc_send_config_pkt(hif_drv->wilc, GET_CFG, &wid, 1,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
if (result) {
PRINT_ER("Failed to get incative time\n");
pu8CurrByte += pstrSetBeaconParam->tail_len;
result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
if (result)
PRINT_ER("Failed to send add beacon config packet\n");
PRINT_D(HOSTINF_DBG, "Deleting BEACON\n");
result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
if (result)
PRINT_ER("Failed to send delete beacon config packet\n");
}
pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
if (result != 0)
PRINT_ER("Failed to send add station config packet\n");
}
result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
if (result)
PRINT_ER("Failed to send add station config packet\n");
memcpy(pu8CurrByte, pstrDelStaParam->mac_addr, ETH_ALEN);
result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
if (result)
PRINT_ER("Failed to send add station config packet\n");
pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
if (result)
PRINT_ER("Failed to send edit station config packet\n");
wid.val[1] = (s8)pstrHostIfRemainOnChan->ch;
result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
if (result != 0)
PRINT_ER("Failed to set remain on channel\n");
wid.size = sizeof(u16) + 2;
result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
if (result) {
PRINT_ER("Failed to frame register config packet\n");
result = -EINVAL;
wid.val[1] = FALSE_FRMWR_CHANNEL;
result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
if (result != 0) {
PRINT_ER("Failed to set remain on channel\n");
goto _done_;
PRINT_D(HOSTINF_DBG, "Handling Power Management\n");
result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
if (result)
PRINT_ER("Failed to send power management config packet\n");
}
((strHostIfSetMulti->cnt) * ETH_ALEN));
result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
if (result)
PRINT_ER("Failed to send setup multicast config packet\n");
*ptr++ = 32;
result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
if (result)
PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
wid.size = u32MaxAssocRespInfoLen;
result = wilc_send_config_pkt(hif_drv->wilc, GET_CFG, &wid, 1,
- get_id_from_handler(hif_drv));
+ wilc_get_vif_idx(vif));
if (result) {
*pu32RcvdAssocRespInfoLen = 0;
PRINT_ER("Failed to send association response config packet\n");
struct host_if_msg msg;
int id;
struct host_if_drv *hif_drv = NULL;
+ struct wilc_vif *vif;
id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
- hif_drv = get_handler_from_id(id);
+ vif = wilc_get_vif_from_idx(wilc, id);
+ if (!vif)
+ return;
+ hif_drv = vif->hif_drv;
if (!hif_drv || hif_drv == terminated_handle) {
PRINT_ER("NetworkInfo received but driver not init[%p]\n", hif_drv);
msg.id = HOST_IF_MSG_RCVD_NTWRK_INFO;
msg.drv = hif_drv;
+ msg.vif = vif;
msg.body.net_info.len = u32Length;
msg.body.net_info.buffer = kmalloc(u32Length, GFP_KERNEL);
struct host_if_msg msg;
int id;
struct host_if_drv *hif_drv = NULL;
+ struct wilc_vif *vif;
down(&hif_sema_deinit);
id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
- hif_drv = get_handler_from_id(id);
+ vif = wilc_get_vif_from_idx(wilc, id);
+ if (!vif) {
+ up(&hif_sema_deinit);
+ return;
+ }
+
+ hif_drv = vif->hif_drv;
PRINT_D(HOSTINF_DBG, "General asynchronous info packet received\n");
if (!hif_drv || hif_drv == terminated_handle) {
msg.id = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
msg.drv = hif_drv;
+ msg.vif = vif;
msg.body.async_info.len = u32Length;
msg.body.async_info.buffer = kmalloc(u32Length, GFP_KERNEL);
struct host_if_msg msg;
int id;
struct host_if_drv *hif_drv = NULL;
+ struct wilc_vif *vif;
id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
- hif_drv = get_handler_from_id(id);
+ vif = wilc_get_vif_from_idx(wilc, id);
+ if (!vif)
+ return;
+ hif_drv = vif->hif_drv;
PRINT_D(GENERIC_DBG, "Scan notification received %p\n", hif_drv);
msg.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
msg.drv = hif_drv;
+ msg.vif = vif;
result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
if (result)