Skip to content

Commit

Permalink
wilc1000: switch tx queue to normal sk_buff entries
Browse files Browse the repository at this point in the history
Convert to the transmit path to use normal socket-buffer operations
rather than driver-specific structures and functions.

This ends up deleting a fair amount of code and otherwise mostly
consists of switching struct txq_entry_t to struct sk_buff.

Signed-off-by: David Mosberger-Tang <davidm@egauge.net>
  • Loading branch information
dmosberger authored and intel-lab-lkp committed Dec 18, 2021
1 parent e399775 commit e545dfd
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 298 deletions.
35 changes: 8 additions & 27 deletions drivers/net/wireless/microchip/wilc1000/cfg80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -1038,14 +1038,6 @@ void wilc_wfi_p2p_rx(struct wilc_vif *vif, u8 *buff, u32 size)
cfg80211_rx_mgmt(&priv->wdev, freq, 0, buff, size, 0);
}

static void wilc_wfi_mgmt_tx_complete(void *priv, int status)
{
struct wilc_p2p_mgmt_data *pv_data = priv;

kfree(pv_data->buff);
kfree(pv_data);
}

static void wilc_wfi_remain_on_channel_expired(void *data, u64 cookie)
{
struct wilc_vif *vif = data;
Expand Down Expand Up @@ -1124,7 +1116,7 @@ static int mgmt_tx(struct wiphy *wiphy,
const u8 *buf = params->buf;
size_t len = params->len;
const struct ieee80211_mgmt *mgmt;
struct wilc_p2p_mgmt_data *mgmt_tx;
struct sk_buff *skb;
struct wilc_vif *vif = netdev_priv(wdev->netdev);
struct wilc_priv *priv = &vif->priv;
struct host_if_drv *wfi_drv = priv->hif_drv;
Expand All @@ -1141,20 +1133,11 @@ static int mgmt_tx(struct wiphy *wiphy,
if (!ieee80211_is_mgmt(mgmt->frame_control))
goto out;

mgmt_tx = kmalloc(sizeof(*mgmt_tx), GFP_KERNEL);
if (!mgmt_tx) {
ret = -ENOMEM;
goto out;
}

mgmt_tx->buff = kmemdup(buf, len, GFP_KERNEL);
if (!mgmt_tx->buff) {
ret = -ENOMEM;
kfree(mgmt_tx);
goto out;
}
skb = wilc_wlan_alloc_skb(vif, len);
if (!skb)
return -ENOMEM;

mgmt_tx->size = len;
skb_put_data(skb, buf, len);

if (ieee80211_is_probe_resp(mgmt->frame_control)) {
wilc_set_mac_chnl_num(vif, chan->hw_value);
Expand All @@ -1176,7 +1159,7 @@ static int mgmt_tx(struct wiphy *wiphy,
goto out_set_timeout;

vendor_ie = cfg80211_find_vendor_ie(WLAN_OUI_WFA, WLAN_OUI_TYPE_WFA_P2P,
mgmt_tx->buff + ie_offset,
skb->data + ie_offset,
len - ie_offset);
if (!vendor_ie)
goto out_set_timeout;
Expand All @@ -1189,9 +1172,7 @@ static int mgmt_tx(struct wiphy *wiphy,

out_txq_add_pkt:

wilc_wlan_txq_add_mgmt_pkt(wdev->netdev, mgmt_tx,
mgmt_tx->buff, mgmt_tx->size,
wilc_wfi_mgmt_tx_complete);
wilc_wlan_txq_add_mgmt_pkt(wdev->netdev, skb);

out:

Expand Down Expand Up @@ -1732,7 +1713,7 @@ int wilc_cfg80211_init(struct wilc **wilc, struct device *dev, int io_type,
wl->hif_func = ops;

for (i = 0; i < NQUEUES; i++)
INIT_LIST_HEAD(&wl->txq[i].txq_head.list);
skb_queue_head_init(&wl->txq[i]);

INIT_LIST_HEAD(&wl->rxq_head.list);
INIT_LIST_HEAD(&wl->vif_list);
Expand Down
36 changes: 6 additions & 30 deletions drivers/net/wireless/microchip/wilc1000/mon.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,45 +95,21 @@ void wilc_wfi_monitor_rx(struct net_device *mon_dev, u8 *buff, u32 size)
netif_rx(skb);
}

struct tx_complete_mon_data {
int size;
void *buff;
};

static void mgmt_tx_complete(void *priv, int status)
{
struct tx_complete_mon_data *pv_data = priv;
/*
* in case of fully hosting mode, the freeing will be done
* in response to the cfg packet
*/
kfree(pv_data->buff);

kfree(pv_data);
}

static int mon_mgmt_tx(struct net_device *dev, const u8 *buf, size_t len)
{
struct tx_complete_mon_data *mgmt_tx = NULL;
struct wilc_vif *vif = netdev_priv(dev);
struct sk_buff *skb;

if (!dev)
return -EFAULT;

netif_stop_queue(dev);
mgmt_tx = kmalloc(sizeof(*mgmt_tx), GFP_ATOMIC);
if (!mgmt_tx)
return -ENOMEM;

mgmt_tx->buff = kmemdup(buf, len, GFP_ATOMIC);
if (!mgmt_tx->buff) {
kfree(mgmt_tx);
skb = wilc_wlan_alloc_skb(vif, len);
if (!skb)
return -ENOMEM;
}

mgmt_tx->size = len;
skb_put_data(skb, buf, len);

wilc_wlan_txq_add_mgmt_pkt(dev, mgmt_tx, mgmt_tx->buff, mgmt_tx->size,
mgmt_tx_complete);
wilc_wlan_txq_add_mgmt_pkt(dev, skb);

netif_wake_queue(dev);
return 0;
Expand Down
26 changes: 2 additions & 24 deletions drivers/net/wireless/microchip/wilc1000/netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -718,42 +718,20 @@ static void wilc_set_multicast_list(struct net_device *dev)
kfree(mc_list);
}

static void wilc_tx_complete(void *priv, int status)
{
struct tx_complete_data *pv_data = priv;

dev_kfree_skb(pv_data->skb);
kfree(pv_data);
}

netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct net_device *ndev)
{
struct wilc_vif *vif = netdev_priv(ndev);
struct wilc *wilc = vif->wilc;
struct tx_complete_data *tx_data = NULL;
int queue_count;

if (skb->dev != ndev) {
netdev_err(ndev, "Packet not destined to this device\n");
return NETDEV_TX_OK;
}

tx_data = kmalloc(sizeof(*tx_data), GFP_ATOMIC);
if (!tx_data) {
dev_kfree_skb(skb);
netif_wake_queue(ndev);
return NETDEV_TX_OK;
}

tx_data->buff = skb->data;
tx_data->size = skb->len;
tx_data->skb = skb;

vif->netstats.tx_packets++;
vif->netstats.tx_bytes += tx_data->size;
queue_count = wilc_wlan_txq_add_net_pkt(ndev, tx_data,
tx_data->buff, tx_data->size,
wilc_tx_complete);
vif->netstats.tx_bytes += skb->len;
queue_count = wilc_wlan_txq_add_net_pkt(ndev, skb);

if (queue_count > FLOW_CONTROL_UPPER_THRESHOLD) {
int srcu_idx;
Expand Down
7 changes: 3 additions & 4 deletions drivers/net/wireless/microchip/wilc1000/netdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ struct ack_session_info {
struct pending_acks {
u32 ack_num;
u32 session_index;
struct txq_entry_t *txqe;
struct sk_buff *txqe;
};

struct tcp_ack_filter {
Expand Down Expand Up @@ -245,15 +245,14 @@ struct wilc {

/* lock to protect issue of wid command to firmware */
struct mutex cfg_cmd_lock;
struct wilc_cfg_frame cfg_frame;
u32 cfg_frame_offset;
struct sk_buff *cfg_skb;
u8 cfg_seq_no;

u8 *rx_buffer;
u32 rx_buffer_offset;
u8 *tx_buffer;

struct txq_handle txq[NQUEUES];
struct sk_buff_head txq[NQUEUES];
atomic_t txq_entries;
struct txq_fw_recv_queue_stat fw[NQUEUES];

Expand Down

0 comments on commit e545dfd

Please sign in to comment.