BNX2X: spatch endian converters
authorBarret Rhoden <brho@cs.berkeley.edu>
Mon, 9 Feb 2015 19:52:00 +0000 (14:52 -0500)
committerBarret Rhoden <brho@cs.berkeley.edu>
Mon, 2 Mar 2015 16:59:09 +0000 (11:59 -0500)
kern/drivers/net/bnx2x/bnx2x.h
kern/drivers/net/bnx2x/bnx2x_cmn.c
kern/drivers/net/bnx2x/bnx2x_main.c
scripts/spatch/linux/funcs.cocci

index fcc6960..dc107cc 100644 (file)
@@ -896,7 +896,7 @@ static inline bool bnx2x_fp_ll_disable(struct bnx2x_fastpath *fp)
 #define SKB_CS(skb)            (*(uint16_t *)(skb_transport_header(skb) + \
                                          skb->csum_offset))
 
-#define pbd_tcp_flags(tcp_hdr) (ntohl(tcp_flag_word(tcp_hdr))>>16 & 0xff)
+#define pbd_tcp_flags(tcp_hdr) (be32_to_cpu(tcp_flag_word(tcp_hdr))>>16 & 0xff)
 
 #define XMIT_PLAIN             0
 #define XMIT_CSUM_V4           (1 << 0)
index 7d75cda..abbe541 100644 (file)
@@ -779,7 +779,9 @@ static void bnx2x_tpa_stop(struct bnx2x *bp, struct bnx2x_fastpath *fp,
                if (!bnx2x_fill_frag_skb(bp, fp, tpa_info, pages,
                                         skb, cqe, cqe_idx)) {
                        if (tpa_info->parsing_flags & PARSING_FLAGS_VLAN)
-                               __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), tpa_info->vlan_tag);
+                               __vlan_hwaccel_put_tag(skb,
+                                                      cpu_to_be16(ETH_P_8021Q),
+                                                      tpa_info->vlan_tag);
                        bnx2x_gro_receive(bp, fp, skb);
                } else {
                        DP(NETIF_MSG_RX_STATUS,
@@ -1063,7 +1065,7 @@ reuse_rx:
 
                if (le16_to_cpu(cqe_fp->pars_flags.flags) &
                    PARSING_FLAGS_VLAN)
-                       __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q),
+                       __vlan_hwaccel_put_tag(skb, cpu_to_be16(ETH_P_8021Q),
                                               le16_to_cpu(cqe_fp->vlan_tag));
 
                skb_mark_napi_id(skb, &fp->napi);
@@ -1905,14 +1907,14 @@ uint16_t bnx2x_select_queue(struct ether *dev, struct sk_buff *skb,
 
        if (CNIC_LOADED(bp) && !NO_FCOE(bp)) {
                struct ethhdr *hdr = (struct ethhdr *)skb->data;
-               uint16_t ether_type = ntohs(hdr->h_proto);
+               uint16_t ether_type = be16_to_cpu(hdr->h_proto);
 
                /* Skip VLAN tag if present */
                if (ether_type == ETH_P_8021Q) {
                        struct vlan_ethhdr *vhdr =
                                (struct vlan_ethhdr *)skb->data;
 
-                       ether_type = ntohs(vhdr->h_vlan_encapsulated_proto);
+                       ether_type = be16_to_cpu(vhdr->h_vlan_encapsulated_proto);
                }
 
                /* If ethertype is FCoE or FIP - use FCoE ring */
@@ -3328,7 +3330,7 @@ static uint32_t bnx2x_xmit_type(struct bnx2x *bp, struct sk_buff *skb)
                return XMIT_PLAIN;
 
        protocol = vlan_get_protocol(skb);
-       if (protocol == htons(ETH_P_IPV6)) {
+       if (protocol == cpu_to_be16(ETH_P_IPV6)) {
                rc = XMIT_CSUM_V6;
                prot = ipv6_hdr(skb)->nexthdr;
        } else {
@@ -3873,7 +3875,7 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct ether *dev)
                if (IS_VF(bp))
 #endif
                        tx_start_bd->vlan_or_ethertype =
-                               cpu_to_le16(ntohs(eth->h_proto));
+                               cpu_to_le16(be16_to_cpu(eth->h_proto));
 #ifndef BNX2X_STOP_ON_ERROR
                else
                        /* used by FW for packet accounting */
index 156eb02..9c45106 100644 (file)
@@ -769,7 +769,8 @@ void bnx2x_fw_dump_lvl(struct bnx2x *bp, const char *lvl)
        /* dump buffer after the mark */
        for (offset = mark; offset < trace_shmem_base; offset += 0x8*4) {
                for (word = 0; word < 8; word++)
-                       data[word] = htonl(REG_RD(bp, offset + 4*word));
+                       data[word] = cpu_to_be32(REG_RD(bp,
+                                                offset + 4 * word));
                data[8] = 0x0;
                pr_cont("%s", (char *)data);
        }
@@ -777,7 +778,8 @@ void bnx2x_fw_dump_lvl(struct bnx2x *bp, const char *lvl)
        /* dump buffer before the mark */
        for (offset = addr + 4; offset <= mark; offset += 0x8*4) {
                for (word = 0; word < 8; word++)
-                       data[word] = htonl(REG_RD(bp, offset + 4*word));
+                       data[word] = cpu_to_be32(REG_RD(bp,
+                                                offset + 4 * word));
                data[8] = 0x0;
                pr_cont("%s", (char *)data);
        }
index ee56f62..4824769 100644 (file)
@@ -157,3 +157,26 @@ expression E;
 -ktime_to_ns(E)
 +E
 
+@@
+expression E;
+@@
+-htonl(E)
++cpu_to_be32(E)
+
+@@
+expression E;
+@@
+-htons(E)
++cpu_to_be16(E)
+
+@@
+expression E;
+@@
+-ntohl(E)
++be32_to_cpu(E)
+
+@@
+expression E;
+@@
+-ntohs(E)
++be16_to_cpu(E)