net: stmmac: Improvements for -next
Subsystems (4)
cover net: stmmac: Improvements for -next
Improvements for -next. More info in commit logs.
---
Cc: Giuseppe Cavallaro <[email protected]>
Cc: Alexandre Torgue <[email protected]>
Cc: Jose Abreu <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
Jose Abreu (3):
net: stmmac: Fallback to VLAN Perfect filtering if HASH is not
available
net: stmmac: selftests: Add tests for VLAN Perfect Filtering
net: stmmac: Implement L3/L4 Filters in GMAC4+
drivers/net/ethernet/stmicro/stmmac/dwmac4.h | 21 ++++ drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 118 ++++++++++++++++++++- drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c | 1 + .../net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 17 ++- drivers/net/ethernet/stmicro/stmmac/hwif.h | 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 18 ++-- .../net/ethernet/stmicro/stmmac/stmmac_selftests.c | 114 +++++++++++++------- 7 files changed, 245 insertions(+), 46 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/3 net: stmmac: Fallback to VLAN Perfect filtering if HASH is not available
From: Jose Abreu <[email protected]>
If VLAN Hash Filtering is not available we can fallback to perfect filtering instead. Let's implement this in XGMAC and GMAC cores and let the user use this filter.
VLAN VID=0 always passes filter so we check if more than 2 VLANs are created and return proper error code if so because perfect filtering only supports 1 VID at a time.
---
Cc: Giuseppe Cavallaro <[email protected]>
Cc: Alexandre Torgue <[email protected]>
Cc: Jose Abreu <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 12 +++++++++++- drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 17 ++++++++++++++++- drivers/net/ethernet/stmicro/stmmac/hwif.h | 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 18 ++++++++++++------ 4 files changed, 40 insertions(+), 9 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +11 -1
@@ -733,7 +733,7 @@ static void dwmac4_set_mac_loopback(void __iomem *ioaddr, bool enable) }static void dwmac4_update_vlan_hash (struct mac_device_info *hw,u32 hash, -bool is_double) +u16 perfect_match,bool is_double) {void __iomem *ioaddr = hw->pcsr;
@@ -748,6 +748,16 @@ static void dwmac4_update_vlan_hash(struct mac_device_info *hw, u32 hash, }writel (value, ioaddr +GMAC_VLAN_TAG ); + }else if (perfect_match) { +u32 value =GMAC_VLAN_ETV ; + +if (is_double) { + value |=GMAC_VLAN_EDVLP ; + value |=GMAC_VLAN_ESVL ; + value |=GMAC_VLAN_DOVLTC ; + } + +writel (value | perfect_match, ioaddr +GMAC_VLAN_TAG ); }else {u32 value =readl (ioaddr +GMAC_VLAN_TAG );
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +16 -1
@@ -555,7 +555,7 @@ static int dwxgmac2_rss_configure(struct mac_device_info *hw, }static void dwxgmac2_update_vlan_hash (struct mac_device_info *hw,u32 hash, -bool is_double) +u16 perfect_match,bool is_double) {void __iomem *ioaddr = hw->pcsr;
@@ -576,6 +576,21 @@ static void dwxgmac2_update_vlan_hash(struct mac_device_info *hw, u32 hash, }writel (value, ioaddr +XGMAC_VLAN_TAG ); + }else if (perfect_match) { +u32 value =readl (ioaddr +XGMAC_PACKET_FILTER ); + + value |=XGMAC_FILTER_VTFE ; + +writel (value, ioaddr +XGMAC_PACKET_FILTER ); + + value =XGMAC_VLAN_ETV ; +if (is_double) { + value |=XGMAC_VLAN_EDVLP ; + value |=XGMAC_VLAN_ESVL ; + value |=XGMAC_VLAN_DOVLTC ; + } + +writel (value | perfect_match, ioaddr +XGMAC_VLAN_TAG ); }else {u32 value =readl (ioaddr +XGMAC_PACKET_FILTER );
drivers/net/ethernet/stmicro/stmmac/hwif.h +1 -1
@@ -357,7 +357,7 @@ struct stmmac_ops { struct stmmac_rss *cfg, u32 num_rxq);/* VLAN */ void (*update_vlan_hash)(struct mac_device_info *hw,u32 hash, -bool is_double); +u16 perfect_match,bool is_double);void (*enable_vlan)(struct mac_device_info *hw,u32 type);/* TX Timestamp */ int (*get_mac_tx_timestamp)(struct mac_device_info *hw,u64 *ts);
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +12 -6
@@ -4207,15 +4207,25 @@ static u32 stmmac_vid_crc32_le(__le16 vid_le)static int stmmac_vlan_update (struct stmmac_priv *priv,bool is_double) {u32 crc, hash =0 ; -u16 vid; +int count =0 ; +u16 vid =0 ;for_each_set_bit (vid, priv->active_vlans,VLAN_N_VID ) {__le16 vid_le =cpu_to_le16 (vid); crc =bitrev32 (~stmmac_vid_crc32_le (vid_le)) >>28 ; hash |= (1 << crc); + count++; + } + +if (!priv->dma_cap.vlhash) { +if (count >2 )/* VID = 0 always passes filter */ +return -EOPNOTSUPP ; + + vid =cpu_to_le16 (vid); + hash =0 ; } -return stmmac_update_vlan_hash (priv, priv->hw, hash, is_double); +return stmmac_update_vlan_hash (priv, priv->hw, hash, vid, is_double); }static int stmmac_vlan_rx_add_vid (struct net_device *ndev,__be16 proto,u16 vid)
@@ -4224,8 +4234,6 @@ static int stmmac_vlan_rx_add_vid(struct net_device *ndev, __be16 proto, u16 vidbool is_double = false;int ret; -if (!priv->dma_cap.vlhash) -return -EOPNOTSUPP ;if (be16_to_cpu (proto) ==ETH_P_8021AD ) is_double = true;
@@ -4244,8 +4252,6 @@ static int stmmac_vlan_rx_kill_vid(struct net_device *ndev, __be16 proto, u16 vistruct stmmac_priv *priv =netdev_priv (ndev);bool is_double = false; -if (!priv->dma_cap.vlhash) -return -EOPNOTSUPP ;if (be16_to_cpu (proto) ==ETH_P_8021AD ) is_double = true;
Signature · 1 line
2.7.4
kbuild test robot
build botRe: [PATCH net-next 1/3] net: stmmac: Fallback to VLAN Perfect filtering if HASH is not available
I love your patch! Perhaps something to improve:
Hi Jose,
I love your patch! Perhaps something to improve:
[auto build test WARNING on net-next/master]
url: https://github.com/0day-ci/linux/commits/Jose-Abreu/net-stmmac-Improvements-for-next/20191007-013324
reproduce:
# apt-get install sparse
# sparse version: v0.6.1-rc1-42-g38eda53-dirty
make ARCH=x86_64 allmodconfig
make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'If you fix the issue, kindly add following tag
sparse warnings: (new ones prefixed by >>)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2613:17: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void [noderef] <asn:2> *ioaddr @@ got void [noderef] <asn:2> *ioaddr @@
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2613:17: sparse: expected void [noderef] <asn:2> *ioaddr
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2613:17: sparse: got struct mac_device_info *hw
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:4224:21: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned short [assigned] [usertype] vid @@ got short [assigned] [usertype] vid @@ >> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:4224:21: sparse: expected unsigned short [assigned] [usertype] vid >> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:4224:21: sparse: got restricted __le16 [usertype]
vim +4224 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
4206
4207 static int stmmac_vlan_update(struct stmmac_priv *priv, bool is_double)
4208 {
4209 u32 crc, hash = 0;
4210 int count = 0;
4211 u16 vid = 0;
4212
4213 for_each_set_bit(vid, priv->active_vlans, VLAN_N_VID) {
4214 __le16 vid_le = cpu_to_le16(vid);
4215 crc = bitrev32(~stmmac_vid_crc32_le(vid_le)) >> 28;
4216 hash |= (1 << crc);
4217 count++;
4218 }
4219
4220 if (!priv->dma_cap.vlhash) {
4221 if (count > 2) /* VID = 0 always passes filter */
4222 return -EOPNOTSUPP;
4223
> 4224 vid = cpu_to_le16(vid);
4225 hash = 0;
4226 }
4227
4228 return stmmac_update_vlan_hash(priv, priv->hw, hash, vid, is_double);
4229 }
4230
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
PATCH 2/3 net: stmmac: selftests: Add tests for VLAN Perfect Filtering
In reply to Jose AbreuFrom: Jose Abreu <[email protected]>
Add two new tests for VLAN Perfect Filtering. While at it, increase a little bit the tests strings lenght so that we can have more descriptive test names.
---
Cc: Giuseppe Cavallaro <[email protected]>
Cc: Alexandre Torgue <[email protected]>
Cc: Jose Abreu <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- .../net/ethernet/stmicro/stmmac/stmmac_selftests.c | 114 ++++++++++++++------- 1 file changed, 77 insertions(+), 37 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +77 -37
@@ -823,16 +823,13 @@ static int stmmac_test_vlan_validate(struct sk_buff *skb,return 0 ; } -static int stmmac_test_vlanfilt (struct stmmac_priv *priv) +static int __stmmac_test_vlanfilt (struct stmmac_priv *priv) {struct stmmac_packet_attrs attr = { };struct stmmac_test_priv *tpriv;struct sk_buff *skb =NULL ;int ret =0 , i; -if (!priv->dma_cap.vlhash) -return -EOPNOTSUPP ; - tpriv =kzalloc (sizeof (*tpriv),GFP_KERNEL );if (!tpriv)return -ENOMEM ;
@@ -898,16 +895,32 @@ static int stmmac_test_vlanfilt(struct stmmac_priv *priv)return ret; } -static int stmmac_test_dvlanfilt (struct stmmac_priv *priv) +static int stmmac_test_vlanfilt (struct stmmac_priv *priv) +{ +if (!priv->dma_cap.vlhash) +return -EOPNOTSUPP ; + +return __stmmac_test_vlanfilt (priv); +} + +static int stmmac_test_vlanfilt_perfect (struct stmmac_priv *priv) +{ +int ret, prev_cap = priv->dma_cap.vlhash; + + priv->dma_cap.vlhash =0 ; + ret =__stmmac_test_vlanfilt (priv); + priv->dma_cap.vlhash = prev_cap; + +return ret; +} + +static int __stmmac_test_dvlanfilt (struct stmmac_priv *priv) {struct stmmac_packet_attrs attr = { };struct stmmac_test_priv *tpriv;struct sk_buff *skb =NULL ;int ret =0 , i; -if (!priv->dma_cap.vlhash) -return -EOPNOTSUPP ; - tpriv =kzalloc (sizeof (*tpriv),GFP_KERNEL );if (!tpriv)return -ENOMEM ;
@@ -974,6 +987,25 @@ static int stmmac_test_dvlanfilt(struct stmmac_priv *priv)return ret; } +static int stmmac_test_dvlanfilt (struct stmmac_priv *priv) +{ +if (!priv->dma_cap.vlhash) +return -EOPNOTSUPP ; + +return __stmmac_test_dvlanfilt (priv); +} + +static int stmmac_test_dvlanfilt_perfect (struct stmmac_priv *priv) +{ +int ret, prev_cap = priv->dma_cap.vlhash; + + priv->dma_cap.vlhash =0 ; + ret =__stmmac_test_dvlanfilt (priv); + priv->dma_cap.vlhash = prev_cap; + +return ret; +} +#ifdef CONFIG_NET_CLS_ACT static int stmmac_test_rxp (struct stmmac_priv *priv) {
@@ -1648,119 +1680,127 @@ static const struct stmmac_test { int (*fn)(struct stmmac_priv *priv); } stmmac_selftests[] = { { - .name = "MAC Loopback ", + .name = "MAC Loopback ", .lb = STMMAC_LOOPBACK_MAC, .fn = stmmac_test_mac_loopback, }, { - .name = "PHY Loopback ", + .name = "PHY Loopback ", .lb = STMMAC_LOOPBACK_NONE, /* Test will handle it */ .fn = stmmac_test_phy_loopback, }, { - .name = "MMC Counters ", + .name = "MMC Counters ", .lb = STMMAC_LOOPBACK_PHY, .fn = stmmac_test_mmc, }, { - .name = "EEE ", + .name = "EEE ", .lb = STMMAC_LOOPBACK_PHY, .fn = stmmac_test_eee, }, { - .name = "Hash Filter MC ", + .name = "Hash Filter MC ", .lb = STMMAC_LOOPBACK_PHY, .fn = stmmac_test_hfilt, }, { - .name = "Perfect Filter UC ", + .name = "Perfect Filter UC ", .lb = STMMAC_LOOPBACK_PHY, .fn = stmmac_test_pfilt, }, { - .name = "MC Filter ", + .name = "MC Filter ", .lb = STMMAC_LOOPBACK_PHY, .fn = stmmac_test_mcfilt, }, { - .name = "UC Filter ", + .name = "UC Filter ", .lb = STMMAC_LOOPBACK_PHY, .fn = stmmac_test_ucfilt, }, { - .name = "Flow Control ", + .name = "Flow Control ", .lb = STMMAC_LOOPBACK_PHY, .fn = stmmac_test_flowctrl, }, { - .name = "RSS ", + .name = "RSS ", .lb = STMMAC_LOOPBACK_PHY, .fn = stmmac_test_rss, }, { - .name = "VLAN Filtering ", + .name = "VLAN Filtering ", .lb = STMMAC_LOOPBACK_PHY, .fn = stmmac_test_vlanfilt, }, { - .name = "Double VLAN Filtering", + .name = "VLAN Filtering (perf) ", + .lb = STMMAC_LOOPBACK_PHY, + .fn = stmmac_test_vlanfilt_perfect, + }, { + .name = "Double VLAN Filter ", .lb = STMMAC_LOOPBACK_PHY, .fn = stmmac_test_dvlanfilt, }, { - .name = "Flexible RX Parser ", + .name = "Double VLAN Filter (perf) ", + .lb = STMMAC_LOOPBACK_PHY, + .fn = stmmac_test_dvlanfilt_perfect, + }, { + .name = "Flexible RX Parser ", .lb = STMMAC_LOOPBACK_PHY, .fn = stmmac_test_rxp, }, { - .name = "SA Insertion (desc) ", + .name = "SA Insertion (desc) ", .lb = STMMAC_LOOPBACK_PHY, .fn = stmmac_test_desc_sai, }, { - .name = "SA Replacement (desc)", + .name = "SA Replacement (desc) ", .lb = STMMAC_LOOPBACK_PHY, .fn = stmmac_test_desc_sar, }, { - .name = "SA Insertion (reg) ", + .name = "SA Insertion (reg) ", .lb = STMMAC_LOOPBACK_PHY, .fn = stmmac_test_reg_sai, }, { - .name = "SA Replacement (reg)", + .name = "SA Replacement (reg) ", .lb = STMMAC_LOOPBACK_PHY, .fn = stmmac_test_reg_sar, }, { - .name = "VLAN TX Insertion ", + .name = "VLAN TX Insertion ", .lb = STMMAC_LOOPBACK_PHY, .fn = stmmac_test_vlanoff, }, { - .name = "SVLAN TX Insertion ", + .name = "SVLAN TX Insertion ", .lb = STMMAC_LOOPBACK_PHY, .fn = stmmac_test_svlanoff, }, { - .name = "L3 DA Filtering ", + .name = "L3 DA Filtering ", .lb = STMMAC_LOOPBACK_PHY, .fn = stmmac_test_l3filt_da, }, { - .name = "L3 SA Filtering ", + .name = "L3 SA Filtering ", .lb = STMMAC_LOOPBACK_PHY, .fn = stmmac_test_l3filt_sa, }, { - .name = "L4 DA TCP Filtering ", + .name = "L4 DA TCP Filtering ", .lb = STMMAC_LOOPBACK_PHY, .fn = stmmac_test_l4filt_da_tcp, }, { - .name = "L4 SA TCP Filtering ", + .name = "L4 SA TCP Filtering ", .lb = STMMAC_LOOPBACK_PHY, .fn = stmmac_test_l4filt_sa_tcp, }, { - .name = "L4 DA UDP Filtering ", + .name = "L4 DA UDP Filtering ", .lb = STMMAC_LOOPBACK_PHY, .fn = stmmac_test_l4filt_da_udp, }, { - .name = "L4 SA UDP Filtering ", + .name = "L4 SA UDP Filtering ", .lb = STMMAC_LOOPBACK_PHY, .fn = stmmac_test_l4filt_sa_udp, }, { - .name = "ARP Offload ", + .name = "ARP Offload ", .lb = STMMAC_LOOPBACK_PHY, .fn = stmmac_test_arpoffload, }, { - .name = "Jumbo Frame ", + .name = "Jumbo Frame ", .lb = STMMAC_LOOPBACK_PHY, .fn = stmmac_test_jumbo, }, { - .name = "Multichannel Jumbo ", + .name = "Multichannel Jumbo ", .lb = STMMAC_LOOPBACK_PHY, .fn = stmmac_test_mjumbo, }, { - .name = "Split Header ", + .name = "Split Header ", .lb = STMMAC_LOOPBACK_PHY, .fn = stmmac_test_sph, },
Signature · 1 line
2.7.4
PATCH 3/3 net: stmmac: Implement L3/L4 Filters in GMAC4+
In reply to Jose AbreuFrom: Jose Abreu <[email protected]>
GMAC4+ cores support Layer 3 and Layer 4 filtering. Add the corresponding callbacks in these cores.
---
Cc: Giuseppe Cavallaro <[email protected]>
Cc: Alexandre Torgue <[email protected]>
Cc: Jose Abreu <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- drivers/net/ethernet/stmicro/stmmac/dwmac4.h | 21 +++++ drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 106 ++++++++++++++++++++++ drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c | 1 + 3 files changed, 128 insertions(+)
drivers/net/ethernet/stmicro/stmmac/dwmac4.h +21 -0
@@ -43,6 +43,10 @@#define GMAC_ARP_ADDR 0x00000210#define GMAC_ADDR_HIGH (reg) (0x300 + reg * 8)#define GMAC_ADDR_LOW (reg) (0x304 + reg * 8) +#define GMAC_L3L4_CTRL (reg) (0x900 + (reg) * 0x30) +#define GMAC_L4_ADDR (reg) (0x904 + (reg) * 0x30) +#define GMAC_L3_ADDR0 (reg) (0x910 + (reg) * 0x30) +#define GMAC_L3_ADDR1 (reg) (0x914 + (reg) * 0x30)/* RX Queues Routing */ #define GMAC_RXQCTRL_AVCPQ_MASK GENMASK(2, 0)
@@ -67,6 +71,7 @@#define GMAC_PACKET_FILTER_PCF BIT(7)#define GMAC_PACKET_FILTER_HPF BIT(10)#define GMAC_PACKET_FILTER_VTFE BIT(16) +#define GMAC_PACKET_FILTER_IPFE BIT(20)#define GMAC_MAX_PERFECT_ADDRESSES 128
@@ -202,6 +207,7 @@ enum power_event {#define GMAC_HW_FEAT_MIISEL BIT(0)/* MAC HW features1 bitmap */ +#define GMAC_HW_FEAT_L3L4FNUM GENMASK(30, 27)#define GMAC_HW_HASH_TB_SZ GENMASK(25, 24)#define GMAC_HW_FEAT_AVSEL BIT(20)#define GMAC_HW_TSOEN BIT(18)
@@ -228,6 +234,21 @@ enum power_event {#define GMAC_HI_DCS_SHIFT 16#define GMAC_HI_REG_AE BIT(31) +/* L3/L4 Filters regs */ +#define GMAC_L4DPIM0 BIT(21) +#define GMAC_L4DPM0 BIT(20) +#define GMAC_L4SPIM0 BIT(19) +#define GMAC_L4SPM0 BIT(18) +#define GMAC_L4PEN0 BIT(16) +#define GMAC_L3DAIM0 BIT(5) +#define GMAC_L3DAM0 BIT(4) +#define GMAC_L3SAIM0 BIT(3) +#define GMAC_L3SAM0 BIT(2) +#define GMAC_L3PEN0 BIT(0) +#define GMAC_L4DP0 GENMASK(31, 16) +#define GMAC_L4DP0_SHIFT 16 +#define GMAC_L4SP0 GENMASK(15, 0) +/* MTL registers */ #define MTL_OPERATION_MODE 0x00000c00#define MTL_FRPE BIT(15)
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +106 -0
130 lines not on this page · raw message
drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c +1 -0
@@ -364,6 +364,7 @@ static void dwmac4_get_hw_feature(void __iomem *ioaddr,/* MAC HW feature1 */ hw_cap =readl (ioaddr +GMAC_HW_FEATURE1 ); + dma_cap->l3l4fnum = (hw_cap &GMAC_HW_FEAT_L3L4FNUM ) >>27 ; dma_cap->hash_tb_sz = (hw_cap &GMAC_HW_HASH_TB_SZ ) >>24 ; dma_cap->av = (hw_cap &GMAC_HW_FEAT_AVSEL ) >>20 ; dma_cap->tsoen = (hw_cap &GMAC_HW_TSOEN ) >>18 ;
Signature · 1 line
2.7.4
David Miller
maintainerFrom: Jose Abreu <[email protected]>
Date: Sun, 6 Oct 2019 13:17:11 +0200
Quoted 1 line
Improvements for -next. More info in commit logs.
Series applied but you have to do better than this in your header postings.
This is the place where you must describe the high level purpose of the patch series, what it is implementing, how it is implementing, and why it is implmenting it that way.
Just "look at the commit logs" is not acceptable.
Thank you.