priv->hostt.qtail = (priv->hostt.qtail + 1) % SME_EVENT_BUFF_SIZE;
}
+/* allocate size bytes, set header size and event */
+static void *hostif_generic_request(size_t size, int event)
+{
+ struct hostif_hdr *p;
+
+ p = kzalloc(hif_align_size(size), KS_WLAN_MEM_FLAG);
+ if (!p)
+ return NULL;
+
+ p->size = cpu_to_le16((u16)(size - sizeof(p->size)));
+ p->event = cpu_to_le16(event);
+
+ return p;
+}
+
int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb)
{
unsigned int skb_len = 0;
DPRINTK(3, "\n");
- /* make primitive */
- pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
- if (!pp) {
- DPRINTK(3, "allocate memory failed..\n");
+ pp = hostif_generic_request(sizeof(*pp), HIF_MIB_GET_REQ);
+ if (!pp)
return;
- }
- pp->header.size =
- cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
- pp->header.event = cpu_to_le16((uint16_t)HIF_MIB_GET_REQ);
+
pp->mib_attribute = cpu_to_le32((uint32_t)mib_attribute);
/* send to device request */
return;
}
- /* make primitive */
- pp = kmalloc(hif_align_size(sizeof(*pp) + size), KS_WLAN_MEM_FLAG);
- if (!pp) {
- DPRINTK(3, "allocate memory failed..\n");
+ pp = hostif_generic_request(sizeof(*pp), HIF_MIB_SET_REQ);
+ if (!pp)
return;
- }
- pp->header.size =
- cpu_to_le16((uint16_t)
- (sizeof(*pp) - sizeof(pp->header.size) + size));
- pp->header.event = cpu_to_le16((uint16_t)HIF_MIB_SET_REQ);
pp->mib_attribute = cpu_to_le32((uint32_t)mib_attribute);
pp->mib_value.size = cpu_to_le16((uint16_t)size);
pp->mib_value.type = cpu_to_le16((uint16_t)type);
DPRINTK(3, "\n");
- /* make primitive */
- pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
- if (!pp) {
- DPRINTK(3, "allocate memory failed..\n");
+ pp = hostif_generic_request(sizeof(*pp), HIF_START_REQ);
+ if (!pp)
return;
- }
- pp->header.size =
- cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
- pp->header.event = cpu_to_le16((uint16_t)HIF_START_REQ);
+
pp->mode = cpu_to_le16((uint16_t)mode);
/* send to device request */
DPRINTK(3, "\n");
- /* make primitive */
- pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
- if (!pp) {
- DPRINTK(3, "allocate memory failed..\n");
+ pp = hostif_generic_request(sizeof(*pp), HIF_PS_ADH_SET_REQ);
+ if (!pp)
return;
- }
- memset(pp, 0, sizeof(*pp));
- pp->header.size =
- cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
- pp->header.event = cpu_to_le16((uint16_t)HIF_PS_ADH_SET_REQ);
+
pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type));
pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode));
pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type));
DPRINTK(3, "ssid.size=%d\n", priv->reg.ssid.size);
- /* make primitive */
- pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
- if (!pp) {
- DPRINTK(3, "allocate memory failed..\n");
+ pp = hostif_generic_request(sizeof(*pp), HIF_INFRA_SET_REQ);
+ if (!pp)
return;
- }
- pp->header.size =
- cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
- pp->header.event = cpu_to_le16((uint16_t)HIF_INFRA_SET_REQ);
+
pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type));
pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode));
pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type));
DPRINTK(2, "ssid.size=%d\n", priv->reg.ssid.size);
- /* make primitive */
- pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
- if (!pp) {
- DPRINTK(3, "allocate memory failed..\n");
+ pp = hostif_generic_request(sizeof(*pp), HIF_INFRA_SET2_REQ);
+ if (!pp)
return;
- }
- pp->header.size =
- cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
- pp->header.event = cpu_to_le16((uint16_t)HIF_INFRA_SET2_REQ);
+
pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type));
pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode));
pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type));
DPRINTK(3, "\n");
- /* make primitive */
- pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
- if (!pp) {
- DPRINTK(3, "allocate memory failed..\n");
+ pp = hostif_generic_request(sizeof(*pp), HIF_ADH_SET_REQ);
+ if (!pp)
return;
- }
- memset(pp, 0, sizeof(*pp));
- pp->header.size =
- cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
- pp->header.event = cpu_to_le16((uint16_t)HIF_ADH_SET_REQ);
+
pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type));
pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode));
pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type));
DPRINTK(3, "\n");
- /* make primitive */
- pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
- if (!pp) {
- DPRINTK(3, "allocate memory failed..\n");
+ pp = hostif_generic_request(sizeof(*pp), HIF_ADH_SET_REQ);
+ if (!pp)
return;
- }
- memset(pp, 0, sizeof(*pp));
- pp->header.size =
- cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
- pp->header.event = cpu_to_le16((uint16_t)HIF_ADH_SET_REQ);
+
pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type));
pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode));
pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type));
DPRINTK(3, "\n");
- /* make primitive */
- pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
- if (!pp) {
- DPRINTK(3, "allocate memory failed..\n");
+ pp = hostif_generic_request(sizeof(*pp), HIF_STOP_REQ);
+ if (!pp)
return;
- }
- pp->header.size =
- cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
- pp->header.event = cpu_to_le16((uint16_t)HIF_STOP_REQ);
/* send to device request */
ps_confirm_wait_inc(priv);
DPRINTK(3, "\n");
- /* make primitive */
- pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
- if (!pp) {
- DPRINTK(3, "allocate memory failed..\n");
+ pp = hostif_generic_request(sizeof(*pp), HIF_PHY_INFO_REQ);
+ if (!pp)
return;
- }
- pp->header.size =
- cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
- pp->header.event = cpu_to_le16((uint16_t)HIF_PHY_INFO_REQ);
+
if (priv->reg.phy_info_timer) {
pp->type = cpu_to_le16((uint16_t)TIME_TYPE);
pp->time = cpu_to_le16((uint16_t)(priv->reg.phy_info_timer));
DPRINTK(3, "mode=%lu wake_up=%lu receiveDTIMs=%lu\n", mode, wake_up,
receiveDTIMs);
- /* make primitive */
- pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
- if (!pp) {
- DPRINTK(3, "allocate memory failed..\n");
+
+ pp = hostif_generic_request(sizeof(*pp), HIF_POWERMGT_REQ);
+ if (!pp)
return;
- }
- pp->header.size =
- cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
- pp->header.event = cpu_to_le16((uint16_t)HIF_POWERMGT_REQ);
+
pp->mode = cpu_to_le32((uint32_t)mode);
pp->wake_up = cpu_to_le32((uint32_t)wake_up);
pp->receiveDTIMs = cpu_to_le32((uint32_t)receiveDTIMs);
DPRINTK(3, "mode=%lu\n", mode);
if (mode == SLP_SLEEP) {
- /* make primitive */
- pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
- if (!pp) {
- DPRINTK(3, "allocate memory failed..\n");
+ pp = hostif_generic_request(sizeof(*pp), HIF_SLEEP_REQ);
+ if (!pp)
return;
- }
- pp->header.size =
- cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
- pp->header.event = cpu_to_le16((uint16_t)HIF_SLEEP_REQ);
/* send to device request */
ps_confirm_wait_inc(priv);
struct hostif_bss_scan_request_t *pp;
DPRINTK(2, "\n");
- /* make primitive */
- pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
- if (!pp) {
- DPRINTK(3, "allocate memory failed..\n");
+
+ pp = hostif_generic_request(sizeof(*pp), HIF_SCAN_REQ);
+ if (!pp)
return;
- }
- pp->header.size =
- cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
- pp->header.event = cpu_to_le16((uint16_t)HIF_SCAN_REQ);
+
pp->scan_type = scan_type;
pp->ch_time_min = cpu_to_le32((uint32_t)110); /* default value */
struct hostif_mic_failure_request_t *pp;
DPRINTK(3, "count=%d :: timer=%d\n", failure_count, timer);
- /* make primitive */
- pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
- if (!pp) {
- DPRINTK(3, "allocate memory failed..\n");
+
+ pp = hostif_generic_request(sizeof(*pp), HIF_MIC_FAILURE_REQ);
+ if (!pp)
return;
- }
- pp->header.size =
- cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
- pp->header.event = cpu_to_le16((uint16_t)HIF_MIC_FAILURE_REQ);
+
pp->failure_count = cpu_to_le16((uint16_t)failure_count);
pp->timer = cpu_to_le16((uint16_t)timer);