]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
bnxt_en: Refactor bnxt_gro_skb().
authorMichael Chan <michael.chan@broadcom.com>
Mon, 13 Jun 2016 06:25:34 +0000 (02:25 -0400)
committerChuck Anderson <chuck.anderson@oracle.com>
Thu, 7 Jul 2016 00:37:30 +0000 (17:37 -0700)
Orabug: 23221795

Newer chips require different logic to handle GRO packets.  So refactor
the code so that we can call different functions depending on the chip.

Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 309369c9b3f6a8665e581d9014f222b602f6845a)
Signed-off-by: Brian Maly <brian.maly@oracle.com>
drivers/net/ethernet/broadcom/bnxt/bnxt.c
drivers/net/ethernet/broadcom/bnxt/bnxt.h

index 15c7fd011f9732c302d8295fd07afc82b62a315e..a6d01f4c31c439fb5f86a4ff0d5f59414a2aae09 100644 (file)
@@ -948,29 +948,15 @@ static void bnxt_abort_tpa(struct bnxt *bp, struct bnxt_napi *bnapi,
 #define BNXT_IPV4_HDR_SIZE     (sizeof(struct iphdr) + sizeof(struct tcphdr))
 #define BNXT_IPV6_HDR_SIZE     (sizeof(struct ipv6hdr) + sizeof(struct tcphdr))
 
-static inline struct sk_buff *bnxt_gro_skb(struct bnxt_tpa_info *tpa_info,
-                                          struct rx_tpa_end_cmp *tpa_end,
-                                          struct rx_tpa_end_cmp_ext *tpa_end1,
+static struct sk_buff *bnxt_gro_func_5730x(struct bnxt_tpa_info *tpa_info,
+                                          int payload_off, int tcp_ts,
                                           struct sk_buff *skb)
 {
 #ifdef CONFIG_INET
        struct tcphdr *th;
-       int payload_off, tcp_opt_len = 0;
-       int len, nw_off;
-       u16 segs;
-
-       segs = TPA_END_TPA_SEGS(tpa_end);
-       if (segs == 1)
-               return skb;
+       int len, nw_off, tcp_opt_len;
 
-       NAPI_GRO_CB(skb)->count = segs;
-       skb_shinfo(skb)->gso_size =
-               le32_to_cpu(tpa_end1->rx_tpa_end_cmp_seg_len);
-       skb_shinfo(skb)->gso_type = tpa_info->gso_type;
-       payload_off = (le32_to_cpu(tpa_end->rx_tpa_end_cmp_misc_v1) &
-                      RX_TPA_END_CMP_PAYLOAD_OFFSET) >>
-                     RX_TPA_END_CMP_PAYLOAD_OFFSET_SHIFT;
-       if (TPA_END_GRO_TS(tpa_end))
+       if (tcp_ts)
                tcp_opt_len = 12;
 
        if (tpa_info->gso_type == SKB_GSO_TCPV4) {
@@ -1027,6 +1013,32 @@ static inline struct sk_buff *bnxt_gro_skb(struct bnxt_tpa_info *tpa_info,
        return skb;
 }
 
+static inline struct sk_buff *bnxt_gro_skb(struct bnxt *bp,
+                                          struct bnxt_tpa_info *tpa_info,
+                                          struct rx_tpa_end_cmp *tpa_end,
+                                          struct rx_tpa_end_cmp_ext *tpa_end1,
+                                          struct sk_buff *skb)
+{
+#ifdef CONFIG_INET
+       int payload_off;
+       u16 segs;
+
+       segs = TPA_END_TPA_SEGS(tpa_end);
+       if (segs == 1)
+               return skb;
+
+       NAPI_GRO_CB(skb)->count = segs;
+       skb_shinfo(skb)->gso_size =
+               le32_to_cpu(tpa_end1->rx_tpa_end_cmp_seg_len);
+       skb_shinfo(skb)->gso_type = tpa_info->gso_type;
+       payload_off = (le32_to_cpu(tpa_end->rx_tpa_end_cmp_misc_v1) &
+                      RX_TPA_END_CMP_PAYLOAD_OFFSET) >>
+                     RX_TPA_END_CMP_PAYLOAD_OFFSET_SHIFT;
+       skb = bp->gro_func(tpa_info, payload_off, TPA_END_GRO_TS(tpa_end), skb);
+#endif
+       return skb;
+}
+
 static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp,
                                           struct bnxt_napi *bnapi,
                                           u32 *raw_cons,
@@ -1137,7 +1149,7 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp,
        }
 
        if (TPA_END_GRO(tpa_end))
-               skb = bnxt_gro_skb(tpa_info, tpa_end, tpa_end1, skb);
+               skb = bnxt_gro_skb(bp, tpa_info, tpa_end, tpa_end1, skb);
 
        return skb;
 }
@@ -6474,6 +6486,8 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
        if (rc)
                goto init_err;
 
+       bp->gro_func = bnxt_gro_func_5730x;
+
        rc = bnxt_hwrm_func_drv_rgtr(bp);
        if (rc)
                goto init_err;
index b754be60f829864eab320d231c7d92a1410e21c0..d62f4c2039f8d23eb52f801df84a39fe48d3c7b4 100644 (file)
@@ -953,6 +953,9 @@ struct bnxt {
        struct bnxt_rx_ring_info        *rx_ring;
        struct bnxt_tx_ring_info        *tx_ring;
 
+       struct sk_buff *        (*gro_func)(struct bnxt_tpa_info *, int, int,
+                                           struct sk_buff *);
+
        u32                     rx_buf_size;
        u32                     rx_buf_use_size;        /* useable size */
        u32                     rx_ring_size;