diff mbox series

[v2,37/50] wilc1000: introduce set_header() function

Message ID 20211223011358.4031459-38-davidm@egauge.net
State New
Headers show
Series wilc1000: rework tx path to use sk_buffs throughout | expand

Commit Message

David Mosberger-Tang Dec. 23, 2021, 1:14 a.m. UTC
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(-)

Comments

kernel test robot Dec. 28, 2021, 3 p.m. UTC | #1
Hi David,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on kvalo-wireless-drivers-next/master]
[also build test WARNING on kvalo-wireless-drivers/master v5.16-rc7 next-20211224]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/David-Mosberger-Tang/wilc1000-rework-tx-path-to-use-sk_buffs-throughout/20211223-091915
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git master
config: sparc-randconfig-s031-20211228 (https://download.01.org/0day-ci/archive/20211228/202112282213.rH4qGL7z-lkp@intel.com/config)
compiler: sparc64-linux-gcc (GCC) 11.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.4-dirty
        # https://github.com/0day-ci/linux/commit/65a4186b405c72cc6e1a405db7ed0145a28a372f
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review David-Mosberger-Tang/wilc1000-rework-tx-path-to-use-sk_buffs-throughout/20211223-091915
        git checkout 65a4186b405c72cc6e1a405db7ed0145a28a372f
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=sparc SHELL=/bin/bash drivers/net/wireless/microchip/wilc1000/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


sparse warnings: (new ones prefixed by >>)
   drivers/net/wireless/microchip/wilc1000/wlan.c:640:16: sparse: sparse: incorrect type in return expression (different base types) @@     expected unsigned int @@     got restricted __le32 [usertype] @@
   drivers/net/wireless/microchip/wilc1000/wlan.c:640:16: sparse:     expected unsigned int
   drivers/net/wireless/microchip/wilc1000/wlan.c:640:16: sparse:     got restricted __le32 [usertype]
>> drivers/net/wireless/microchip/wilc1000/wlan.c:660:17: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned int [usertype] vmm_hdr @@     got restricted __le32 [usertype] @@
   drivers/net/wireless/microchip/wilc1000/wlan.c:660:17: sparse:     expected unsigned int [usertype] vmm_hdr
   drivers/net/wireless/microchip/wilc1000/wlan.c:660:17: sparse:     got restricted __le32 [usertype]
>> drivers/net/wireless/microchip/wilc1000/wlan.c:668:22: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned int [usertype] prio @@     got restricted __le32 [usertype] @@
   drivers/net/wireless/microchip/wilc1000/wlan.c:668:22: sparse:     expected unsigned int [usertype] prio
   drivers/net/wireless/microchip/wilc1000/wlan.c:668:22: sparse:     got restricted __le32 [usertype]

vim +660 drivers/net/wireless/microchip/wilc1000/wlan.c

   642	
   643	/**
   644	 * set_header() - set WILC-specific header
   645	 * @wilc: Pointer to the wilc structure.
   646	 * @tqe: The packet to add to the chip queue.
   647	 * @vmm_sz: The final size of the packet, including VMM header and padding.
   648	 * @hdr: Pointer to the header to set
   649	 */
   650	static void set_header(struct wilc *wilc, struct sk_buff *tqe,
   651			       u32 vmm_sz, void *hdr)
   652	{
   653		struct wilc_skb_tx_cb *tx_cb = WILC_SKB_TX_CB(tqe);
   654		u32 mgmt_pkt = 0, vmm_hdr, prio, data_len = tqe->len;
   655		struct wilc_vif *vif;
   656	
   657		/* add the VMM header word: */
   658		if (tx_cb->type == WILC_MGMT_PKT)
   659			mgmt_pkt = FIELD_PREP(WILC_VMM_HDR_MGMT_FIELD, 1);
 > 660		vmm_hdr = cpu_to_le32(mgmt_pkt |
   661				      FIELD_PREP(WILC_VMM_HDR_TYPE, tx_cb->type) |
   662				      FIELD_PREP(WILC_VMM_HDR_PKT_SIZE, data_len) |
   663				      FIELD_PREP(WILC_VMM_HDR_BUFF_SIZE, vmm_sz));
   664		memcpy(hdr, &vmm_hdr, 4);
   665	
   666		if (tx_cb->type == WILC_NET_PKT) {
   667			vif = netdev_priv(tqe->dev);
 > 668			prio = cpu_to_le32(tx_cb->q_num);
   669			memcpy(hdr + 4, &prio, sizeof(prio));
   670			memcpy(hdr + 8, vif->bssid, ETH_ALEN);
   671		}
   672	}
   673	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

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++;