lkml.org 
[lkml]   [2021]   [Dec]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 37/50] wilc1000: introduce set_header() function
Date
Refactor the transmit packet header initialization into its own
set_header() function.

Signed-off-by: David Mosberger-Tang <davidm@egauge.net>
---
.../net/wireless/microchip/wilc1000/wlan.c | 56 +++++++++++--------
1 file changed, 33 insertions(+), 23 deletions(-)

diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c
index c3802a34defed..86b945e5ee076 100644
--- a/drivers/net/wireless/microchip/wilc1000/wlan.c
+++ b/drivers/net/wireless/microchip/wilc1000/wlan.c
@@ -640,6 +640,37 @@ static u32 vmm_table_entry(struct sk_buff *tqe, u32 vmm_sz)
return cpu_to_le32(entry);
}

+/**
+ * set_header() - set WILC-specific header
+ * @wilc: Pointer to the wilc structure.
+ * @tqe: The packet to add to the chip queue.
+ * @vmm_sz: The final size of the packet, including VMM header and padding.
+ * @hdr: Pointer to the header to set
+ */
+static void set_header(struct wilc *wilc, struct sk_buff *tqe,
+ u32 vmm_sz, void *hdr)
+{
+ struct wilc_skb_tx_cb *tx_cb = WILC_SKB_TX_CB(tqe);
+ u32 mgmt_pkt = 0, vmm_hdr, prio, data_len = tqe->len;
+ struct wilc_vif *vif;
+
+ /* add the VMM header word: */
+ if (tx_cb->type == WILC_MGMT_PKT)
+ mgmt_pkt = FIELD_PREP(WILC_VMM_HDR_MGMT_FIELD, 1);
+ vmm_hdr = cpu_to_le32(mgmt_pkt |
+ FIELD_PREP(WILC_VMM_HDR_TYPE, tx_cb->type) |
+ FIELD_PREP(WILC_VMM_HDR_PKT_SIZE, data_len) |
+ FIELD_PREP(WILC_VMM_HDR_BUFF_SIZE, vmm_sz));
+ memcpy(hdr, &vmm_hdr, 4);
+
+ if (tx_cb->type == WILC_NET_PKT) {
+ vif = netdev_priv(tqe->dev);
+ prio = cpu_to_le32(tx_cb->q_num);
+ memcpy(hdr + 4, &prio, sizeof(prio));
+ memcpy(hdr + 8, vif->bssid, ETH_ALEN);
+ }
+}
+
/**
* fill_vmm_table() - Fill VMM table with packets to be sent
* @wilc: Pointer to the wilc structure.
@@ -827,7 +858,6 @@ static int copy_packets(struct wilc *wilc, int entries, u32 *vmm_table,
u8 ac_pkt_num_to_chip[NQUEUES] = {0, 0, 0, 0};
struct wilc_skb_tx_cb *tx_cb;
u8 *txb = wilc->tx_buffer;
- struct wilc_vif *vif;
int i, vmm_sz;
u32 offset;

@@ -835,9 +865,7 @@ static int copy_packets(struct wilc *wilc, int entries, u32 *vmm_table,
i = 0;
do {
struct sk_buff *tqe;
- u32 header, buffer_offset;
- char *bssid;
- u8 mgmt_ptk = 0;
+ u32 buffer_offset;

tqe = skb_dequeue(&wilc->txq[vmm_entries_ac[i]]);
if (!tqe)
@@ -845,7 +873,6 @@ static int copy_packets(struct wilc *wilc, int entries, u32 *vmm_table,

atomic_dec(&wilc->txq_entries);
ac_pkt_num_to_chip[vmm_entries_ac[i]]++;
- vif = netdev_priv(tqe->dev);
tx_cb = WILC_SKB_TX_CB(tqe);
if (vmm_table[i] == 0)
break;
@@ -854,25 +881,8 @@ static int copy_packets(struct wilc *wilc, int entries, u32 *vmm_table,
vmm_sz = FIELD_GET(WILC_VMM_BUFFER_SIZE, vmm_table[i]);
vmm_sz *= 4;

- if (tx_cb->type == WILC_MGMT_PKT)
- mgmt_ptk = 1;
-
- header = (FIELD_PREP(WILC_VMM_HDR_TYPE, tx_cb->type) |
- FIELD_PREP(WILC_VMM_HDR_MGMT_FIELD, mgmt_ptk) |
- FIELD_PREP(WILC_VMM_HDR_PKT_SIZE, tqe->len) |
- FIELD_PREP(WILC_VMM_HDR_BUFF_SIZE, vmm_sz));
-
- cpu_to_le32s(&header);
- memcpy(&txb[offset], &header, 4);
buffer_offset = tx_hdr_len(tx_cb->type);
- if (tx_cb->type == WILC_NET_PKT) {
- int prio = tx_cb->q_num;
-
- bssid = vif->bssid;
- memcpy(&txb[offset + 4], &prio, sizeof(prio));
- memcpy(&txb[offset + 8], bssid, 6);
- }
-
+ set_header(wilc, tqe, vmm_sz, txb + offset);
memcpy(&txb[offset + buffer_offset], tqe->data, tqe->len);
offset += vmm_sz;
i++;
--
2.25.1
\
 
 \ /
  Last update: 2021-12-23 02:16    [W:2.298 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site