From 65a22d84ad1a921751ac9e5a1a5b52dad6967e16 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Mon, 20 Jun 2016 22:38:01 +0200 Subject: [PATCH] kernel: backport bgmac changes from net-next MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Rafał Miłecki --- ...ac-fix-a-missing-check-for-build_skb.patch | 28 +++ ...ersed-test-of-build_skb-return-value.patch | 22 +++ ...-checking-for-BCM4707-BCM53018-chip-.patch | 12 +- ...port-Ethernet-device-on-BCM47094-SoC.patch | 2 +- ...enable-Ethernet-core-before-using-it.patch | 2 +- ...device-with-backing-device-structure.patch | 25 +++ ...c-Add-support-for-ethtool-statistics.patch | 175 ++++++++++++++++++ ...gmac-Maintain-some-netdev-statistics.patch | 68 +++++++ .../773-bgmac-add-srab-switch.patch | 6 +- 9 files changed, 329 insertions(+), 11 deletions(-) create mode 100644 target/linux/generic/patches-4.4/070-0001-bgmac-fix-a-missing-check-for-build_skb.patch create mode 100644 target/linux/generic/patches-4.4/070-0002-bgmac-Fix-reversed-test-of-build_skb-return-value.patch create mode 100644 target/linux/generic/patches-4.4/072-0001-bgmac-Bind-net_device-with-backing-device-structure.patch create mode 100644 target/linux/generic/patches-4.4/072-0002-bgmac-Add-support-for-ethtool-statistics.patch create mode 100644 target/linux/generic/patches-4.4/072-0003-bgmac-Maintain-some-netdev-statistics.patch diff --git a/target/linux/generic/patches-4.4/070-0001-bgmac-fix-a-missing-check-for-build_skb.patch b/target/linux/generic/patches-4.4/070-0001-bgmac-fix-a-missing-check-for-build_skb.patch new file mode 100644 index 0000000000..7e6dc2035d --- /dev/null +++ b/target/linux/generic/patches-4.4/070-0001-bgmac-fix-a-missing-check-for-build_skb.patch @@ -0,0 +1,28 @@ +From f1640c3ddeec12804bc9a21feee85fc15aca95f6 Mon Sep 17 00:00:00 2001 +From: wangweidong +Date: Wed, 13 Jan 2016 11:06:41 +0800 +Subject: [PATCH] bgmac: fix a missing check for build_skb + +when build_skb failed, it may occure a NULL pointer. +So add a 'NULL check' for it. + +Signed-off-by: Weidong Wang +Signed-off-by: David S. Miller +--- + drivers/net/ethernet/broadcom/bgmac.c | 5 +++++ + 1 file changed, 5 insertions(+) + +--- a/drivers/net/ethernet/broadcom/bgmac.c ++++ b/drivers/net/ethernet/broadcom/bgmac.c +@@ -466,6 +466,11 @@ static int bgmac_dma_rx_read(struct bgma + len -= ETH_FCS_LEN; + + skb = build_skb(buf, BGMAC_RX_ALLOC_SIZE); ++ if (unlikely(skb)) { ++ bgmac_err(bgmac, "build_skb failed\n"); ++ put_page(virt_to_head_page(buf)); ++ break; ++ } + skb_put(skb, BGMAC_RX_FRAME_OFFSET + + BGMAC_RX_BUF_OFFSET + len); + skb_pull(skb, BGMAC_RX_FRAME_OFFSET + diff --git a/target/linux/generic/patches-4.4/070-0002-bgmac-Fix-reversed-test-of-build_skb-return-value.patch b/target/linux/generic/patches-4.4/070-0002-bgmac-Fix-reversed-test-of-build_skb-return-value.patch new file mode 100644 index 0000000000..0b0a28d81a --- /dev/null +++ b/target/linux/generic/patches-4.4/070-0002-bgmac-Fix-reversed-test-of-build_skb-return-value.patch @@ -0,0 +1,22 @@ +From 750afbf8ee9c6a1c74a1fe5fc9852146b1d72687 Mon Sep 17 00:00:00 2001 +From: "David S. Miller" +Date: Fri, 15 Jan 2016 16:07:13 -0500 +Subject: [PATCH] bgmac: Fix reversed test of build_skb() return value. + +Fixes: f1640c3ddeec ("bgmac: fix a missing check for build_skb") +Signed-off-by: David S. Miller +--- + drivers/net/ethernet/broadcom/bgmac.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/ethernet/broadcom/bgmac.c ++++ b/drivers/net/ethernet/broadcom/bgmac.c +@@ -466,7 +466,7 @@ static int bgmac_dma_rx_read(struct bgma + len -= ETH_FCS_LEN; + + skb = build_skb(buf, BGMAC_RX_ALLOC_SIZE); +- if (unlikely(skb)) { ++ if (unlikely(!skb)) { + bgmac_err(bgmac, "build_skb failed\n"); + put_page(virt_to_head_page(buf)); + break; diff --git a/target/linux/generic/patches-4.4/071-0001-bgmac-add-helper-checking-for-BCM4707-BCM53018-chip-.patch b/target/linux/generic/patches-4.4/071-0001-bgmac-add-helper-checking-for-BCM4707-BCM53018-chip-.patch index 63010c1450..4008c29963 100644 --- a/target/linux/generic/patches-4.4/071-0001-bgmac-add-helper-checking-for-BCM4707-BCM53018-chip-.patch +++ b/target/linux/generic/patches-4.4/071-0001-bgmac-add-helper-checking-for-BCM4707-BCM53018-chip-.patch @@ -36,7 +36,7 @@ Signed-off-by: David S. Miller static bool bgmac_wait_value(struct bcma_device *core, u16 reg, u32 mask, u32 value, int timeout) { -@@ -982,11 +993,9 @@ static void bgmac_mac_speed(struct bgmac +@@ -987,11 +998,9 @@ static void bgmac_mac_speed(struct bgmac static void bgmac_miiconfig(struct bgmac *bgmac) { struct bcma_device *core = bgmac->core; @@ -49,7 +49,7 @@ Signed-off-by: David S. Miller bcma_awrite32(core, BCMA_IOCTL, bcma_aread32(core, BCMA_IOCTL) | 0x40 | BGMAC_BCMA_IOCTL_SW_CLKEN); -@@ -1050,9 +1059,7 @@ static void bgmac_chip_reset(struct bgma +@@ -1055,9 +1064,7 @@ static void bgmac_chip_reset(struct bgma } /* Request Misc PLL for corerev > 2 */ @@ -60,7 +60,7 @@ Signed-off-by: David S. Miller bgmac_set(bgmac, BCMA_CLKCTLST, BGMAC_BCMA_CLKCTLST_MISC_PLL_REQ); bgmac_wait_value(bgmac->core, BCMA_CLKCTLST, -@@ -1188,8 +1195,7 @@ static void bgmac_enable(struct bgmac *b +@@ -1193,8 +1200,7 @@ static void bgmac_enable(struct bgmac *b break; } @@ -70,7 +70,7 @@ Signed-off-by: David S. Miller rxq_ctl = bgmac_read(bgmac, BGMAC_RXQ_CTL); rxq_ctl &= ~BGMAC_RXQ_CTL_MDP_MASK; bp_clk = bcma_pmu_get_bus_clock(&bgmac->core->bus->drv_cc) / -@@ -1467,14 +1473,12 @@ static int bgmac_fixed_phy_register(stru +@@ -1472,14 +1478,12 @@ static int bgmac_fixed_phy_register(stru static int bgmac_mii_register(struct bgmac *bgmac) { @@ -86,7 +86,7 @@ Signed-off-by: David S. Miller return bgmac_fixed_phy_register(bgmac); mii_bus = mdiobus_alloc(); -@@ -1545,7 +1549,6 @@ static void bgmac_mii_unregister(struct +@@ -1550,7 +1554,6 @@ static void bgmac_mii_unregister(struct /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipattach */ static int bgmac_probe(struct bcma_device *core) { @@ -94,7 +94,7 @@ Signed-off-by: David S. Miller struct net_device *net_dev; struct bgmac *bgmac; struct ssb_sprom *sprom = &core->bus->sprom; -@@ -1626,8 +1629,7 @@ static int bgmac_probe(struct bcma_devic +@@ -1631,8 +1634,7 @@ static int bgmac_probe(struct bcma_devic bgmac_chip_reset(bgmac); /* For Northstar, we have to take all GMAC core out of reset */ diff --git a/target/linux/generic/patches-4.4/071-0002-bgmac-support-Ethernet-device-on-BCM47094-SoC.patch b/target/linux/generic/patches-4.4/071-0002-bgmac-support-Ethernet-device-on-BCM47094-SoC.patch index 88db7b2fff..514fe26f1b 100644 --- a/target/linux/generic/patches-4.4/071-0002-bgmac-support-Ethernet-device-on-BCM47094-SoC.patch +++ b/target/linux/generic/patches-4.4/071-0002-bgmac-support-Ethernet-device-on-BCM47094-SoC.patch @@ -25,7 +25,7 @@ Signed-off-by: David S. Miller case BCMA_CHIP_ID_BCM53018: return true; default: -@@ -1047,8 +1048,9 @@ static void bgmac_chip_reset(struct bgma +@@ -1052,8 +1053,9 @@ static void bgmac_chip_reset(struct bgma (ci->id == BCMA_CHIP_ID_BCM53572 && ci->pkg == BCMA_PKG_ID_BCM47188)) iost &= ~BGMAC_BCMA_IOST_ATTACHED; diff --git a/target/linux/generic/patches-4.4/071-0003-bgmac-reset-enable-Ethernet-core-before-using-it.patch b/target/linux/generic/patches-4.4/071-0003-bgmac-reset-enable-Ethernet-core-before-using-it.patch index 1306072c84..4375868b16 100644 --- a/target/linux/generic/patches-4.4/071-0003-bgmac-reset-enable-Ethernet-core-before-using-it.patch +++ b/target/linux/generic/patches-4.4/071-0003-bgmac-reset-enable-Ethernet-core-before-using-it.patch @@ -17,7 +17,7 @@ Signed-off-by: David S. Miller --- a/drivers/net/ethernet/broadcom/bgmac.c +++ b/drivers/net/ethernet/broadcom/bgmac.c -@@ -1578,6 +1578,11 @@ static int bgmac_probe(struct bcma_devic +@@ -1583,6 +1583,11 @@ static int bgmac_probe(struct bcma_devic dev_warn(&core->dev, "Using random MAC: %pM\n", mac); } diff --git a/target/linux/generic/patches-4.4/072-0001-bgmac-Bind-net_device-with-backing-device-structure.patch b/target/linux/generic/patches-4.4/072-0001-bgmac-Bind-net_device-with-backing-device-structure.patch new file mode 100644 index 0000000000..764b16801d --- /dev/null +++ b/target/linux/generic/patches-4.4/072-0001-bgmac-Bind-net_device-with-backing-device-structure.patch @@ -0,0 +1,25 @@ +From 2022e9d50798aa592887ccb5a7d045e537f3855f Mon Sep 17 00:00:00 2001 +From: Florian Fainelli +Date: Tue, 7 Jun 2016 15:06:13 -0700 +Subject: [PATCH 1/3] bgmac: Bind net_device with backing device structure + +In preparation for allowing different helpers to be utilized against +network devices created by the bgmac driver, make sure that we bind the +net_device with core->dev. + +Signed-off-by: Florian Fainelli +Signed-off-by: David S. Miller +--- + drivers/net/ethernet/broadcom/bgmac.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/net/ethernet/broadcom/bgmac.c ++++ b/drivers/net/ethernet/broadcom/bgmac.c +@@ -1599,6 +1599,7 @@ static int bgmac_probe(struct bcma_devic + bgmac->net_dev = net_dev; + bgmac->core = core; + bcma_set_drvdata(core, bgmac); ++ SET_NETDEV_DEV(net_dev, &core->dev); + + /* Defaults */ + memcpy(bgmac->net_dev->dev_addr, mac, ETH_ALEN); diff --git a/target/linux/generic/patches-4.4/072-0002-bgmac-Add-support-for-ethtool-statistics.patch b/target/linux/generic/patches-4.4/072-0002-bgmac-Add-support-for-ethtool-statistics.patch new file mode 100644 index 0000000000..8f6b6c80fc --- /dev/null +++ b/target/linux/generic/patches-4.4/072-0002-bgmac-Add-support-for-ethtool-statistics.patch @@ -0,0 +1,175 @@ +From f6613d4fa937fa8388f2c1cb4e69ccc25e9e2336 Mon Sep 17 00:00:00 2001 +From: Florian Fainelli +Date: Tue, 7 Jun 2016 15:06:14 -0700 +Subject: [PATCH 2/3] bgmac: Add support for ethtool statistics + +Read the statistics from the BGMAC's builtin MAC and return them to +user-space using the standard ethtool helpers. + +Signed-off-by: Florian Fainelli +Signed-off-by: David S. Miller +--- + drivers/net/ethernet/broadcom/bgmac.c | 124 ++++++++++++++++++++++++++++++++++ + drivers/net/ethernet/broadcom/bgmac.h | 4 +- + 2 files changed, 126 insertions(+), 2 deletions(-) + +--- a/drivers/net/ethernet/broadcom/bgmac.c ++++ b/drivers/net/ethernet/broadcom/bgmac.c +@@ -1382,6 +1382,127 @@ static const struct net_device_ops bgmac + * ethtool_ops + **************************************************/ + ++struct bgmac_stat { ++ u8 size; ++ u32 offset; ++ const char *name; ++}; ++ ++static struct bgmac_stat bgmac_get_strings_stats[] = { ++ { 8, BGMAC_TX_GOOD_OCTETS, "tx_good_octets" }, ++ { 4, BGMAC_TX_GOOD_PKTS, "tx_good" }, ++ { 8, BGMAC_TX_OCTETS, "tx_octets" }, ++ { 4, BGMAC_TX_PKTS, "tx_pkts" }, ++ { 4, BGMAC_TX_BROADCAST_PKTS, "tx_broadcast" }, ++ { 4, BGMAC_TX_MULTICAST_PKTS, "tx_multicast" }, ++ { 4, BGMAC_TX_LEN_64, "tx_64" }, ++ { 4, BGMAC_TX_LEN_65_TO_127, "tx_65_127" }, ++ { 4, BGMAC_TX_LEN_128_TO_255, "tx_128_255" }, ++ { 4, BGMAC_TX_LEN_256_TO_511, "tx_256_511" }, ++ { 4, BGMAC_TX_LEN_512_TO_1023, "tx_512_1023" }, ++ { 4, BGMAC_TX_LEN_1024_TO_1522, "tx_1024_1522" }, ++ { 4, BGMAC_TX_LEN_1523_TO_2047, "tx_1523_2047" }, ++ { 4, BGMAC_TX_LEN_2048_TO_4095, "tx_2048_4095" }, ++ { 4, BGMAC_TX_LEN_4096_TO_8191, "tx_4096_8191" }, ++ { 4, BGMAC_TX_LEN_8192_TO_MAX, "tx_8192_max" }, ++ { 4, BGMAC_TX_JABBER_PKTS, "tx_jabber" }, ++ { 4, BGMAC_TX_OVERSIZE_PKTS, "tx_oversize" }, ++ { 4, BGMAC_TX_FRAGMENT_PKTS, "tx_fragment" }, ++ { 4, BGMAC_TX_UNDERRUNS, "tx_underruns" }, ++ { 4, BGMAC_TX_TOTAL_COLS, "tx_total_cols" }, ++ { 4, BGMAC_TX_SINGLE_COLS, "tx_single_cols" }, ++ { 4, BGMAC_TX_MULTIPLE_COLS, "tx_multiple_cols" }, ++ { 4, BGMAC_TX_EXCESSIVE_COLS, "tx_excessive_cols" }, ++ { 4, BGMAC_TX_LATE_COLS, "tx_late_cols" }, ++ { 4, BGMAC_TX_DEFERED, "tx_defered" }, ++ { 4, BGMAC_TX_CARRIER_LOST, "tx_carrier_lost" }, ++ { 4, BGMAC_TX_PAUSE_PKTS, "tx_pause" }, ++ { 4, BGMAC_TX_UNI_PKTS, "tx_unicast" }, ++ { 4, BGMAC_TX_Q0_PKTS, "tx_q0" }, ++ { 8, BGMAC_TX_Q0_OCTETS, "tx_q0_octets" }, ++ { 4, BGMAC_TX_Q1_PKTS, "tx_q1" }, ++ { 8, BGMAC_TX_Q1_OCTETS, "tx_q1_octets" }, ++ { 4, BGMAC_TX_Q2_PKTS, "tx_q2" }, ++ { 8, BGMAC_TX_Q2_OCTETS, "tx_q2_octets" }, ++ { 4, BGMAC_TX_Q3_PKTS, "tx_q3" }, ++ { 8, BGMAC_TX_Q3_OCTETS, "tx_q3_octets" }, ++ { 8, BGMAC_RX_GOOD_OCTETS, "rx_good_octets" }, ++ { 4, BGMAC_RX_GOOD_PKTS, "rx_good" }, ++ { 8, BGMAC_RX_OCTETS, "rx_octets" }, ++ { 4, BGMAC_RX_PKTS, "rx_pkts" }, ++ { 4, BGMAC_RX_BROADCAST_PKTS, "rx_broadcast" }, ++ { 4, BGMAC_RX_MULTICAST_PKTS, "rx_multicast" }, ++ { 4, BGMAC_RX_LEN_64, "rx_64" }, ++ { 4, BGMAC_RX_LEN_65_TO_127, "rx_65_127" }, ++ { 4, BGMAC_RX_LEN_128_TO_255, "rx_128_255" }, ++ { 4, BGMAC_RX_LEN_256_TO_511, "rx_256_511" }, ++ { 4, BGMAC_RX_LEN_512_TO_1023, "rx_512_1023" }, ++ { 4, BGMAC_RX_LEN_1024_TO_1522, "rx_1024_1522" }, ++ { 4, BGMAC_RX_LEN_1523_TO_2047, "rx_1523_2047" }, ++ { 4, BGMAC_RX_LEN_2048_TO_4095, "rx_2048_4095" }, ++ { 4, BGMAC_RX_LEN_4096_TO_8191, "rx_4096_8191" }, ++ { 4, BGMAC_RX_LEN_8192_TO_MAX, "rx_8192_max" }, ++ { 4, BGMAC_RX_JABBER_PKTS, "rx_jabber" }, ++ { 4, BGMAC_RX_OVERSIZE_PKTS, "rx_oversize" }, ++ { 4, BGMAC_RX_FRAGMENT_PKTS, "rx_fragment" }, ++ { 4, BGMAC_RX_MISSED_PKTS, "rx_missed" }, ++ { 4, BGMAC_RX_CRC_ALIGN_ERRS, "rx_crc_align" }, ++ { 4, BGMAC_RX_UNDERSIZE, "rx_undersize" }, ++ { 4, BGMAC_RX_CRC_ERRS, "rx_crc" }, ++ { 4, BGMAC_RX_ALIGN_ERRS, "rx_align" }, ++ { 4, BGMAC_RX_SYMBOL_ERRS, "rx_symbol" }, ++ { 4, BGMAC_RX_PAUSE_PKTS, "rx_pause" }, ++ { 4, BGMAC_RX_NONPAUSE_PKTS, "rx_nonpause" }, ++ { 4, BGMAC_RX_SACHANGES, "rx_sa_changes" }, ++ { 4, BGMAC_RX_UNI_PKTS, "rx_unicast" }, ++}; ++ ++#define BGMAC_STATS_LEN ARRAY_SIZE(bgmac_get_strings_stats) ++ ++static int bgmac_get_sset_count(struct net_device *dev, int string_set) ++{ ++ switch (string_set) { ++ case ETH_SS_STATS: ++ return BGMAC_STATS_LEN; ++ } ++ ++ return -EOPNOTSUPP; ++} ++ ++static void bgmac_get_strings(struct net_device *dev, u32 stringset, ++ u8 *data) ++{ ++ int i; ++ ++ if (stringset != ETH_SS_STATS) ++ return; ++ ++ for (i = 0; i < BGMAC_STATS_LEN; i++) ++ strlcpy(data + i * ETH_GSTRING_LEN, ++ bgmac_get_strings_stats[i].name, ETH_GSTRING_LEN); ++} ++ ++static void bgmac_get_ethtool_stats(struct net_device *dev, ++ struct ethtool_stats *ss, uint64_t *data) ++{ ++ struct bgmac *bgmac = netdev_priv(dev); ++ const struct bgmac_stat *s; ++ unsigned int i; ++ u64 val; ++ ++ if (!netif_running(dev)) ++ return; ++ ++ for (i = 0; i < BGMAC_STATS_LEN; i++) { ++ s = &bgmac_get_strings_stats[i]; ++ val = 0; ++ if (s->size == 8) ++ val = (u64)bgmac_read(bgmac, s->offset + 4) << 32; ++ val |= bgmac_read(bgmac, s->offset); ++ data[i] = val; ++ } ++} ++ + static int bgmac_get_settings(struct net_device *net_dev, + struct ethtool_cmd *cmd) + { +@@ -1406,6 +1527,9 @@ static void bgmac_get_drvinfo(struct net + } + + static const struct ethtool_ops bgmac_ethtool_ops = { ++ .get_strings = bgmac_get_strings, ++ .get_sset_count = bgmac_get_sset_count, ++ .get_ethtool_stats = bgmac_get_ethtool_stats, + .get_settings = bgmac_get_settings, + .set_settings = bgmac_set_settings, + .get_drvinfo = bgmac_get_drvinfo, +--- a/drivers/net/ethernet/broadcom/bgmac.h ++++ b/drivers/net/ethernet/broadcom/bgmac.h +@@ -123,7 +123,7 @@ + #define BGMAC_TX_LEN_1024_TO_1522 0x334 + #define BGMAC_TX_LEN_1523_TO_2047 0x338 + #define BGMAC_TX_LEN_2048_TO_4095 0x33c +-#define BGMAC_TX_LEN_4095_TO_8191 0x340 ++#define BGMAC_TX_LEN_4096_TO_8191 0x340 + #define BGMAC_TX_LEN_8192_TO_MAX 0x344 + #define BGMAC_TX_JABBER_PKTS 0x348 /* Error */ + #define BGMAC_TX_OVERSIZE_PKTS 0x34c /* Error */ +@@ -166,7 +166,7 @@ + #define BGMAC_RX_LEN_1024_TO_1522 0x3e4 + #define BGMAC_RX_LEN_1523_TO_2047 0x3e8 + #define BGMAC_RX_LEN_2048_TO_4095 0x3ec +-#define BGMAC_RX_LEN_4095_TO_8191 0x3f0 ++#define BGMAC_RX_LEN_4096_TO_8191 0x3f0 + #define BGMAC_RX_LEN_8192_TO_MAX 0x3f4 + #define BGMAC_RX_JABBER_PKTS 0x3f8 /* Error */ + #define BGMAC_RX_OVERSIZE_PKTS 0x3fc /* Error */ diff --git a/target/linux/generic/patches-4.4/072-0003-bgmac-Maintain-some-netdev-statistics.patch b/target/linux/generic/patches-4.4/072-0003-bgmac-Maintain-some-netdev-statistics.patch new file mode 100644 index 0000000000..17a7ce060c --- /dev/null +++ b/target/linux/generic/patches-4.4/072-0003-bgmac-Maintain-some-netdev-statistics.patch @@ -0,0 +1,68 @@ +From 6d490f62a4c7f11c552591bdd08eda3636aa0db9 Mon Sep 17 00:00:00 2001 +From: Florian Fainelli +Date: Tue, 7 Jun 2016 15:06:15 -0700 +Subject: [PATCH 3/3] bgmac: Maintain some netdev statistics + +Add a few netdev statistics to report transmitted and received bytes and +packets and a few obvious errors. + +Signed-off-by: Florian Fainelli +Signed-off-by: David S. Miller +--- + drivers/net/ethernet/broadcom/bgmac.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +--- a/drivers/net/ethernet/broadcom/bgmac.c ++++ b/drivers/net/ethernet/broadcom/bgmac.c +@@ -246,6 +246,8 @@ err_dma_head: + + err_drop: + dev_kfree_skb(skb); ++ net_dev->stats.tx_dropped++; ++ net_dev->stats.tx_errors++; + return NETDEV_TX_OK; + } + +@@ -284,6 +286,8 @@ static void bgmac_dma_tx_free(struct bgm + DMA_TO_DEVICE); + + if (slot->skb) { ++ bgmac->net_dev->stats.tx_bytes += slot->skb->len; ++ bgmac->net_dev->stats.tx_packets++; + bytes_compl += slot->skb->len; + pkts_compl++; + +@@ -464,6 +468,7 @@ static int bgmac_dma_rx_read(struct bgma + bgmac_err(bgmac, "Found poisoned packet at slot %d, DMA issue!\n", + ring->start); + put_page(virt_to_head_page(buf)); ++ bgmac->net_dev->stats.rx_errors++; + break; + } + +@@ -471,6 +476,8 @@ static int bgmac_dma_rx_read(struct bgma + bgmac_err(bgmac, "Found oversized packet at slot %d, DMA issue!\n", + ring->start); + put_page(virt_to_head_page(buf)); ++ bgmac->net_dev->stats.rx_length_errors++; ++ bgmac->net_dev->stats.rx_errors++; + break; + } + +@@ -481,6 +488,7 @@ static int bgmac_dma_rx_read(struct bgma + if (unlikely(!skb)) { + bgmac_err(bgmac, "build_skb failed\n"); + put_page(virt_to_head_page(buf)); ++ bgmac->net_dev->stats.rx_errors++; + break; + } + skb_put(skb, BGMAC_RX_FRAME_OFFSET + +@@ -490,6 +498,8 @@ static int bgmac_dma_rx_read(struct bgma + + skb_checksum_none_assert(skb); + skb->protocol = eth_type_trans(skb, bgmac->net_dev); ++ bgmac->net_dev->stats.rx_bytes += len; ++ bgmac->net_dev->stats.rx_packets++; + napi_gro_receive(&bgmac->napi, skb); + handled++; + } while (0); diff --git a/target/linux/generic/patches-4.4/773-bgmac-add-srab-switch.patch b/target/linux/generic/patches-4.4/773-bgmac-add-srab-switch.patch index 8a68e7e401..4348574cbb 100644 --- a/target/linux/generic/patches-4.4/773-bgmac-add-srab-switch.patch +++ b/target/linux/generic/patches-4.4/773-bgmac-add-srab-switch.patch @@ -12,7 +12,7 @@ Signed-off-by: Hauke Mehrtens #include static const struct bcma_device_id bgmac_bcma_tbl[] = { -@@ -1544,6 +1545,17 @@ static void bgmac_mii_unregister(struct +@@ -1683,6 +1684,17 @@ static void bgmac_mii_unregister(struct mdiobus_free(mii_bus); } @@ -30,7 +30,7 @@ Signed-off-by: Hauke Mehrtens /************************************************** * BCMA bus ops **************************************************/ -@@ -1688,6 +1700,14 @@ static int bgmac_probe(struct bcma_devic +@@ -1828,6 +1840,14 @@ static int bgmac_probe(struct bcma_devic net_dev->hw_features = net_dev->features; net_dev->vlan_features = net_dev->features; @@ -45,7 +45,7 @@ Signed-off-by: Hauke Mehrtens err = register_netdev(bgmac->net_dev); if (err) { bgmac_err(bgmac, "Cannot register net device\n"); -@@ -1714,6 +1734,10 @@ static void bgmac_remove(struct bcma_dev +@@ -1854,6 +1874,10 @@ static void bgmac_remove(struct bcma_dev { struct bgmac *bgmac = bcma_get_drvdata(core); -- 2.25.1