net: stmmac: Improvements for -next
Subsystems (4)
cover net: stmmac: Improvements for -next
Couple of improvements for -next tree. More info in commit logs. Some of them includes fixes for features that are only in -next tree.
---
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 (13):
net: stmmac: selftests: Return proper error code to userspace
net: stmmac: xgmac: Add RBU handling in DMA interrupt
net: stmmac: Do not return error code in TC Initialization
net: stmmac: Implement L3/L4 Filters using TC Flower
net: stmmac: selftests: Add selftest for L3/L4 Filters
net: stmmac: xgmac: Implement ARP Offload
net: stmmac: selftests: Implement the ARP Offload test
net: stmmac: Only consider RX error when HW Timestamping is not
enabled
net: stmmac: ethtool: Let user configure TX coalesce without RIWT
net: stmmac: xgmac: Correct RAVSEL field interpretation
net: stmmac: Correctly assing MAX MTU in XGMAC cores case
net: stmmac: xgmac: Enable RX Jumbo frame support
net: stmmac: selftests: Add Jumbo Frame tests
drivers/net/ethernet/stmicro/stmmac/common.h | 2 + drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h | 33 +- .../net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 205 +++++++++- drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c | 8 +- drivers/net/ethernet/stmicro/stmmac/hwif.h | 19 + drivers/net/ethernet/stmicro/stmmac/stmmac.h | 12 + .../net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 21 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 18 +- .../net/ethernet/stmicro/stmmac/stmmac_selftests.c | 451 ++++++++++++++++++++- drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c | 247 ++++++++++- 10 files changed, 969 insertions(+), 47 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/13 net: stmmac: selftests: Return proper error code to userspace
We can do better than just return 1 to userspace. Lets return a proper Linux error code.
---
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 | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +11 -11
@@ -318,7 +318,7 @@ static int __stmmac_test_loopback(struct stmmac_priv *priv, attr->timeout =STMMAC_LB_TIMEOUT ;wait_for_completion_timeout (&tpriv->comp, attr->timeout); - ret = !tpriv->ok; + ret = tpriv->ok ?0 : -ETIMEDOUT ; cleanup:if (!attr->dont_wait)
@@ -480,7 +480,7 @@ static int stmmac_test_hfilt(struct stmmac_priv *priv)/* Shall NOT receive packet */ ret =__stmmac_test_loopback (priv, &attr); - ret = !ret; + ret = ret ?0 : -EINVAL ; cleanup:dev_mc_del (priv->dev, gd_addr);
@@ -512,7 +512,7 @@ static int stmmac_test_pfilt(struct stmmac_priv *priv)/* Shall NOT receive packet */ ret =__stmmac_test_loopback (priv, &attr); - ret = !ret; + ret = ret ?0 : -EINVAL ; cleanup:dev_uc_del (priv->dev, gd_addr);
@@ -562,7 +562,7 @@ static int stmmac_test_mcfilt(struct stmmac_priv *priv)/* Shall NOT receive packet */ ret =__stmmac_test_loopback (priv, &attr); - ret = !ret; + ret = ret ?0 : -EINVAL ; cleanup:dev_uc_del (priv->dev, uc_addr);
@@ -600,7 +600,7 @@ static int stmmac_test_ucfilt(struct stmmac_priv *priv)/* Shall NOT receive packet */ ret =__stmmac_test_loopback (priv, &attr); - ret = !ret; + ret = ret ?0 : -EINVAL ; cleanup:dev_mc_del (priv->dev, mc_addr);
@@ -699,7 +699,7 @@ static int stmmac_test_flowctrl(struct stmmac_priv *priv) }wait_for_completion_timeout (&tpriv->comp,STMMAC_LB_TIMEOUT ); - ret = !tpriv->ok; + ret = tpriv->ok ?0 : -ETIMEDOUT ; cleanup:dev_mc_del (priv->dev, paddr);
@@ -833,11 +833,11 @@ static int stmmac_test_vlanfilt(struct stmmac_priv *priv) goto vlan_del;wait_for_completion_timeout (&tpriv->comp,STMMAC_LB_TIMEOUT ); - ret = !tpriv->ok; + ret = tpriv->ok ?0 : -ETIMEDOUT ;if (ret && !i) { goto vlan_del; }else if (!ret && i) { - ret =-1 ; + ret = -EINVAL ; goto vlan_del; }else { ret =0 ;
@@ -909,11 +909,11 @@ static int stmmac_test_dvlanfilt(struct stmmac_priv *priv) goto vlan_del;wait_for_completion_timeout (&tpriv->comp,STMMAC_LB_TIMEOUT ); - ret = !tpriv->ok; + ret = tpriv->ok ?0 : -ETIMEDOUT ;if (ret && !i) { goto vlan_del; }else if (!ret && i) { - ret =-1 ; + ret = -EINVAL ; goto vlan_del; }else { ret =0 ;
@@ -998,7 +998,7 @@ static int stmmac_test_rxp(struct stmmac_priv *priv) attr.src = addr; ret =__stmmac_test_loopback (priv, &attr); - ret = !ret;/* Shall NOT receive packet */ + ret = ret ?0 : -EINVAL ;/* Shall NOT receive packet */ cls_u32.command =TC_CLSU32_DELETE_KNODE ;stmmac_tc_setup_cls_u32 (priv, priv, &cls_u32);
Signature · 1 line
2.7.4
PATCH 2/13 net: stmmac: xgmac: Add RBU handling in DMA interrupt
In reply to Jose AbreuAdd the handling of Receive Buffer Unavailable interrupt in the DMA handler of XGMAC 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/dwxgmac2_dma.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c +4 -0
@@ -322,6 +322,10 @@ static int dwxgmac2_dma_interrupt(void __iomem *ioaddr,/* ABNORMAL interrupts */ if (unlikely (intr_status &XGMAC_AIS )) { +if (unlikely (intr_status &XGMAC_RBU )) { + x->rx_buf_unav_irq++; + ret |= handle_rx; + }if (unlikely (intr_status &XGMAC_TPS )) { x->tx_process_stopped_irq++; ret |= tx_hard_error;
Signature · 1 line
2.7.4
PATCH 3/13 net: stmmac: Do not return error code in TC Initialization
In reply to Jose AbreuAs we can still use the remaining TC callbacks, e.g. CBS. We should not fail in the initialization only because RX Parser is not available.
---
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/stmmac_tc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +2 -1
@@ -243,8 +243,9 @@ static int tc_init(struct stmmac_priv *priv)struct dma_features *dma_cap = &priv->dma_cap;unsigned int count; +/* Fail silently as we can still use remaining features, e.g. CBS */ if (!dma_cap->frpsel) -return -EINVAL ; +return 0 ;switch (dma_cap->frpbs) {case 0x0 :
Signature · 1 line
2.7.4
PATCH 4/13 net: stmmac: Implement L3/L4 Filters using TC Flower
In reply to Jose AbreuImplement filters for Layer 3 and Layer 4 using TC Flower API. Add the corresponding callbacks in XGMAC core.
---
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/common.h | 1 + drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h | 30 +++ .../net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 177 +++++++++++++++ drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c | 1 + drivers/net/ethernet/stmicro/stmmac/hwif.h | 16 ++ drivers/net/ethernet/stmicro/stmmac/stmmac.h | 12 + drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 9 +- drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c | 244 +++++++++++++++++++++ 8 files changed, 488 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/common.h +1 -0
@@ -360,6 +360,7 @@ struct dma_features {unsigned int sphen;unsigned int vlins;unsigned int dvlan; +unsigned int l3l4fnum; };/* GMAC TX FIFO is 8K, Rx FIFO is 16K */
drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h +30 -0
@@ -47,6 +47,7 @@#define XGMAC_CORE_INIT_RX 0#define XGMAC_PACKET_FILTER 0x00000008#define XGMAC_FILTER_RA BIT(31) +#define XGMAC_FILTER_IPFE BIT(20)#define XGMAC_FILTER_VTFE BIT(16)#define XGMAC_FILTER_HPF BIT(10)#define XGMAC_FILTER_PCF BIT(7)
@@ -119,6 +120,7 @@#define XGMAC_HWFEAT_VLHASH BIT(4)#define XGMAC_HWFEAT_GMIISEL BIT(1)#define XGMAC_HW_FEATURE1 0x00000120 +#define XGMAC_HWFEAT_L3L4FNUM GENMASK(30, 27)#define XGMAC_HWFEAT_RSSEN BIT(20)#define XGMAC_HWFEAT_TSOEN BIT(18)#define XGMAC_HWFEAT_SPHEN BIT(17)
@@ -150,6 +152,34 @@#define XGMAC_DCS GENMASK(19, 16)#define XGMAC_DCS_SHIFT 16#define XGMAC_ADDRx_LOW (x) (0x00000304 + (x) * 0x8) +#define XGMAC_L3L4_ADDR_CTRL 0x00000c00 +#define XGMAC_IDDR GENMASK(15, 8) +#define XGMAC_IDDR_SHIFT 8 +#define XGMAC_IDDR_FNUM 4 +#define XGMAC_TT BIT(1) +#define XGMAC_XB BIT(0) +#define XGMAC_L3L4_DATA 0x00000c04 +#define XGMAC_L3L4_CTRL 0x0 +#define XGMAC_L4DPIM0 BIT(21) +#define XGMAC_L4DPM0 BIT(20) +#define XGMAC_L4SPIM0 BIT(19) +#define XGMAC_L4SPM0 BIT(18) +#define XGMAC_L4PEN0 BIT(16) +#define XGMAC_L3HDBM0 GENMASK(15, 11) +#define XGMAC_L3HSBM0 GENMASK(10, 6) +#define XGMAC_L3DAIM0 BIT(5) +#define XGMAC_L3DAM0 BIT(4) +#define XGMAC_L3SAIM0 BIT(3) +#define XGMAC_L3SAM0 BIT(2) +#define XGMAC_L3PEN0 BIT(0) +#define XGMAC_L4_ADDR 0x1 +#define XGMAC_L4DP0 GENMASK(31, 16) +#define XGMAC_L4DP0_SHIFT 16 +#define XGMAC_L4SP0 GENMASK(15, 0) +#define XGMAC_L3_ADDR0 0x4 +#define XGMAC_L3_ADDR1 0x5 +#define XGMAC_L3_ADDR2 0x6 +#define XMGAC_L3_ADDR3 0x7#define XGMAC_ARP_ADDR 0x00000c10#define XGMAC_RSS_CTRL 0x00000c80#define XGMAC_UDP4TE BIT(3)
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +177 -0
189 lines not on this page · raw message
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c +1 -0
@@ -378,6 +378,7 @@ static void dwxgmac2_get_hw_feature(void __iomem *ioaddr,/* MAC HW feature 1 */ hw_cap =readl (ioaddr +XGMAC_HW_FEATURE1 ); + dma_cap->l3l4fnum = (hw_cap &XGMAC_HWFEAT_L3L4FNUM ) >>27 ; dma_cap->rssen = (hw_cap &XGMAC_HWFEAT_RSSEN ) >>20 ; dma_cap->tsoen = (hw_cap &XGMAC_HWFEAT_TSOEN ) >>18 ; dma_cap->sphen = (hw_cap &XGMAC_HWFEAT_SPHEN ) >>17 ;
drivers/net/ethernet/stmicro/stmmac/hwif.h +16 -0
@@ -363,6 +363,13 @@ struct stmmac_ops {int (*get_mac_tx_timestamp)(struct mac_device_info *hw,u64 *ts);/* Source Address Insertion / Replacement */ void (*sarc_configure)(void __iomem *ioaddr,int val); +/* Filtering */ +int (*config_l3_filter)(struct mac_device_info *hw,u32 filter_no, +bool en,bool ipv6,bool sa,bool inv, +u32 match); +int (*config_l4_filter)(struct mac_device_info *hw,u32 filter_no, +bool en,bool udp,bool sa,bool inv, +u32 match); }; #define stmmac_core_init(__priv, __args...) \
@@ -443,6 +450,10 @@ struct stmmac_ops { stmmac_do_callback(__priv, mac, get_mac_tx_timestamp, __args) #define stmmac_sarc_configure(__priv, __args...) \ stmmac_do_void_callback(__priv, mac, sarc_configure, __args) +#define stmmac_config_l3_filter(__priv, __args...) \ + stmmac_do_callback(__priv, mac, config_l3_filter, __args) +#define stmmac_config_l4_filter(__priv, __args...) \ + stmmac_do_callback(__priv, mac, config_l4_filter, __args)/* PTP and HW Timer helpers */ struct stmmac_hwtimestamp {
@@ -499,6 +510,7 @@ struct stmmac_mode_ops {struct stmmac_priv ;struct tc_cls_u32_offload ;struct tc_cbs_qopt_offload ; +struct flow_cls_offload ;struct stmmac_tc_ops {int (*init)(struct stmmac_priv *priv);
@@ -506,6 +518,8 @@ struct stmmac_tc_ops { struct tc_cls_u32_offload *cls);int (*setup_cbs)(struct stmmac_priv *priv,struct tc_cbs_qopt_offload *qopt); +int (*setup_cls)(struct stmmac_priv *priv, +struct flow_cls_offload *cls); }; #define stmmac_tc_init(__priv, __args...) \
@@ -514,6 +528,8 @@ struct stmmac_tc_ops { stmmac_do_callback(__priv, tc, setup_cls_u32, __args) #define stmmac_tc_setup_cbs(__priv, __args...) \ stmmac_do_callback(__priv, tc, setup_cbs, __args) +#define stmmac_tc_setup_cls(__priv, __args...) \ + stmmac_do_callback(__priv, tc, setup_cls, __args)struct stmmac_counters ;
drivers/net/ethernet/stmicro/stmmac/stmmac.h +12 -0
@@ -128,6 +128,16 @@ struct stmmac_rss {u32 table[STMMAC_RSS_MAX_TABLE_SIZE ]; }; +#define STMMAC_FLOW_ACTION_DROP BIT(0) +struct stmmac_flow_entry { +unsigned long cookie; +unsigned long action; +u8 ip_proto; +int in_use; +int idx; +int is_l4; +}; +struct stmmac_priv {/* Frequently used values are kept adjacent for cache effect */ u32 tx_coal_frames;
@@ -216,6 +226,8 @@ struct stmmac_priv {unsigned int tc_entries_max;unsigned int tc_off_max;struct stmmac_tc_entry *tc_entries; +unsigned int flow_entries_max; +struct stmmac_flow_entry *flow_entries;/* Pulse Per Second output */ struct stmmac_pps_cfg pps[STMMAC_PPS_MAX ];
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +7 -2
@@ -3931,12 +3931,17 @@ static int stmmac_setup_tc_block_cb(enum tc_setup_type type, void *type_data,struct stmmac_priv *priv = cb_priv;int ret = -EOPNOTSUPP ; +if (!tc_cls_can_offload_and_chain0 (priv->dev, type_data)) +return ret; +stmmac_disable_all_queues (priv);switch (type) {case TC_SETUP_CLSU32 : -if (tc_cls_can_offload_and_chain0 (priv->dev, type_data)) - ret =stmmac_tc_setup_cls_u32 (priv, priv, type_data); + ret =stmmac_tc_setup_cls_u32 (priv, priv, type_data); +break ; +case TC_SETUP_CLSFLOWER : + ret =stmmac_tc_setup_cls (priv, priv, type_data);break ;default :break ;
drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +244 -0
258 lines not on this page · raw message
Signature · 7 lines
2.7.4 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 5/13 net: stmmac: selftests: Add selftest for L3/L4 Filters
In reply to Jose AbreuAdds the selftests for L3 and L4 filters with DA/SA/DP/SP support.
---
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 | 254 ++++++++++++++++++++- 1 file changed, 253 insertions(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +253 -1
@@ -164,7 +164,7 @@ static struct sk_buff *stmmac_test_get_udp_skb(struct stmmac_priv *priv, iplen +=sizeof (*uhdr); ihdr->tot_len =htons (iplen); ihdr->frag_off =0 ; - ihdr->saddr =0 ; + ihdr->saddr =htonl (attr->ip_src); ihdr->daddr =htonl (attr->ip_dst); ihdr->tos =0 ; ihdr->id =0 ;
@@ -1168,6 +1168,234 @@ static int stmmac_test_svlanoff(struct stmmac_priv *priv)return stmmac_test_vlanoff_common (priv, true); } +#ifdef CONFIG_NET_CLS_ACT +static int __stmmac_test_l3filt (struct stmmac_priv *priv,u32 dst,u32 src, +u32 dst_mask,u32 src_mask) +{ +struct flow_dissector_key_ipv4_addrs key, mask; +unsigned long dummy_cookie =0xdeadbeef ; +struct flow_dissector dissector = { }; +struct stmmac_packet_attrs attr = { }; +struct flow_cls_offload cls = { }; +struct flow_rule *rule; +int ret; + +if (!tc_can_offload (priv->dev)) +return -EOPNOTSUPP ; +if (!priv->dma_cap.l3l4fnum) +return -EOPNOTSUPP ; +if (priv->rss.enable) { +struct stmmac_rss rss = { .enable = false, }; + +stmmac_rss_configure (priv, priv->hw, &rss, + priv->plat->rx_queues_to_use); + } + + dissector.used_keys |= (1 <<FLOW_DISSECTOR_KEY_IPV4_ADDRS ); + dissector.offset[FLOW_DISSECTOR_KEY_IPV4_ADDRS ] =0 ; + + cls.common.chain_index =0 ; + cls.command =FLOW_CLS_REPLACE ; + cls.cookie = dummy_cookie; + + rule =kzalloc (struct_size (rule, action.entries,1 ),GFP_KERNEL ); +if (!rule) { + ret = -ENOMEM ; + goto cleanup_rss; + } + + rule->match.dissector = &dissector; + rule->match.key = (void *)&key; + rule->match.mask = (void *)&mask; + + key.src =htonl (src); + key.dst =htonl (dst); + mask.src = src_mask; + mask.dst = dst_mask; + + cls.rule = rule; + + rule->action.entries[0 ].id =FLOW_ACTION_DROP ; + rule->action.num_entries =1 ; + + attr.dst = priv->dev->dev_addr; + attr.ip_dst = dst; + attr.ip_src = src; + +/* Shall receive packet */ + ret =__stmmac_test_loopback (priv, &attr); +if (ret) + goto cleanup_rule; + + ret =stmmac_tc_setup_cls (priv, priv, &cls); +if (ret) + goto cleanup_rule; + +/* Shall NOT receive packet */ + ret =__stmmac_test_loopback (priv, &attr); + ret = ret ?0 : -EINVAL ; + + cls.command =FLOW_CLS_DESTROY ; +stmmac_tc_setup_cls (priv, priv, &cls); +cleanup_rule: +kfree (rule); +cleanup_rss: +if (priv->rss.enable) { +stmmac_rss_configure (priv, priv->hw, &priv->rss, + priv->plat->rx_queues_to_use); + } + +return ret; +} +#else +static int __stmmac_test_l3filt (struct stmmac_priv *priv,u32 dst,u32 src, +u32 dst_mask,u32 src_mask) +{ +return -EOPNOTSUPP ; +} +#endif + +static int stmmac_test_l3filt_da (struct stmmac_priv *priv) +{ +u32 addr =0x10203040 ; + +return __stmmac_test_l3filt (priv, addr,0 , ~0 ,0 ); +} + +static int stmmac_test_l3filt_sa (struct stmmac_priv *priv) +{ +u32 addr =0x10203040 ; + +return __stmmac_test_l3filt (priv,0 , addr,0 , ~0 ); +} + +#ifdef CONFIG_NET_CLS_ACT +static int __stmmac_test_l4filt (struct stmmac_priv *priv,u32 dst,u32 src, +u32 dst_mask,u32 src_mask,bool udp) +{ +struct { +struct flow_dissector_key_basic bkey; +struct flow_dissector_key_ports key; + }__aligned(BITS_PER_LONG / 8) keys; +struct { +struct flow_dissector_key_basic bmask; +struct flow_dissector_key_ports mask; + }__aligned(BITS_PER_LONG / 8) masks; +unsigned long dummy_cookie =0xdeadbeef ; +struct flow_dissector dissector = { }; +struct stmmac_packet_attrs attr = { }; +struct flow_cls_offload cls = { }; +struct flow_rule *rule; +int ret; + +if (!tc_can_offload (priv->dev)) +return -EOPNOTSUPP ; +if (!priv->dma_cap.l3l4fnum) +return -EOPNOTSUPP ; +if (priv->rss.enable) { +struct stmmac_rss rss = { .enable = false, }; + +stmmac_rss_configure (priv, priv->hw, &rss, + priv->plat->rx_queues_to_use); + } + + dissector.used_keys |= (1 <<FLOW_DISSECTOR_KEY_BASIC ); + dissector.used_keys |= (1 <<FLOW_DISSECTOR_KEY_PORTS ); + dissector.offset[FLOW_DISSECTOR_KEY_BASIC ] =0 ; + dissector.offset[FLOW_DISSECTOR_KEY_PORTS ] = offsetof(typeof (keys ), key); + + cls.common.chain_index =0 ; + cls.command =FLOW_CLS_REPLACE ; + cls.cookie = dummy_cookie; + + rule =kzalloc (struct_size (rule, action.entries,1 ),GFP_KERNEL ); +if (!rule) { + ret = -ENOMEM ; + goto cleanup_rss; + } + + rule->match.dissector = &dissector; + rule->match.key = (void *)&keys; + rule->match.mask = (void *)&masks; + + keys.bkey.ip_proto = udp ?IPPROTO_UDP :IPPROTO_TCP ; + keys.key.src =htons (src); + keys.key.dst =htons (dst); + masks.mask.src = src_mask; + masks.mask.dst = dst_mask; + + cls.rule = rule; + + rule->action.entries[0 ].id =FLOW_ACTION_DROP ; + rule->action.num_entries =1 ; + + attr.dst = priv->dev->dev_addr; + attr.tcp = !udp; + attr.sport = src; + attr.dport = dst; + attr.ip_dst =0 ; + +/* Shall receive packet */ + ret =__stmmac_test_loopback (priv, &attr); +if (ret) + goto cleanup_rule; + + ret =stmmac_tc_setup_cls (priv, priv, &cls); +if (ret) + goto cleanup_rule; + +/* Shall NOT receive packet */ + ret =__stmmac_test_loopback (priv, &attr); + ret = ret ?0 : -EINVAL ; + + cls.command =FLOW_CLS_DESTROY ; +stmmac_tc_setup_cls (priv, priv, &cls); +cleanup_rule: +kfree (rule); +cleanup_rss: +if (priv->rss.enable) { +stmmac_rss_configure (priv, priv->hw, &priv->rss, + priv->plat->rx_queues_to_use); + } + +return ret; +} +#else +static int __stmmac_test_l4filt (struct stmmac_priv *priv,u32 dst,u32 src, +u32 dst_mask,u32 src_mask,bool udp) +{ +return -EOPNOTSUPP ; +} +#endif + +static int stmmac_test_l4filt_da_tcp (struct stmmac_priv *priv) +{ +u16 dummy_port =0x123 ; + +return __stmmac_test_l4filt (priv, dummy_port,0 , ~0 ,0 , false); +} + +static int stmmac_test_l4filt_sa_tcp (struct stmmac_priv *priv) +{ +u16 dummy_port =0x123 ; + +return __stmmac_test_l4filt (priv,0 , dummy_port,0 , ~0 , false); +} + +static int stmmac_test_l4filt_da_udp (struct stmmac_priv *priv) +{ +u16 dummy_port =0x123 ; + +return __stmmac_test_l4filt (priv, dummy_port,0 , ~0 ,0 , true); +} + +static int stmmac_test_l4filt_sa_udp (struct stmmac_priv *priv) +{ +u16 dummy_port =0x123 ; + +return __stmmac_test_l4filt (priv,0 , dummy_port,0 , ~0 , true); +} +#define STMMAC_LOOPBACK_NONE 0#define STMMAC_LOOPBACK_MAC 1#define STMMAC_LOOPBACK_PHY 2
@@ -1253,6 +1481,30 @@ static const struct stmmac_test { .name = "SVLAN TX Insertion ", .lb = STMMAC_LOOPBACK_PHY, .fn = stmmac_test_svlanoff, + }, { + .name = "L3 DA Filtering ", + .lb = STMMAC_LOOPBACK_PHY, + .fn = stmmac_test_l3filt_da, + }, { + .name = "L3 SA Filtering ", + .lb = STMMAC_LOOPBACK_PHY, + .fn = stmmac_test_l3filt_sa, + }, { + .name = "L4 DA TCP Filtering ", + .lb = STMMAC_LOOPBACK_PHY, + .fn = stmmac_test_l4filt_da_tcp, + }, { + .name = "L4 SA TCP Filtering ", + .lb = STMMAC_LOOPBACK_PHY, + .fn = stmmac_test_l4filt_sa_tcp, + }, { + .name = "L4 DA UDP Filtering ", + .lb = STMMAC_LOOPBACK_PHY, + .fn = stmmac_test_l4filt_da_udp, + }, { + .name = "L4 SA UDP Filtering ", + .lb = STMMAC_LOOPBACK_PHY, + .fn = stmmac_test_l4filt_sa_udp, }, };
Signature · 1 line
2.7.4
kbuild test robot
build botRe: [PATCH net-next 05/13] net: stmmac: selftests: Add selftest for L3/L4 Filters
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/20190902-160927
config: mips-allmodconfig (attached as .config)
compiler: mips-linux-gcc (GCC) 7.4.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=mips
If you fix the issue, kindly add following tag
All warnings (new ones prefixed by >>):
drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c: In function '__stmmac_test_l3filt':
>> drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c:1249:1: warning: the frame size of 1280 bytes is larger than 1024 bytes [-Wframe-larger-than=]
}
^
drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c: In function '__stmmac_test_l4filt':
drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c:1362:1: warning: the frame size of 1280 bytes is larger than 1024 bytes [-Wframe-larger-than=]
}
^vim +1249 drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c
1170
1171 #ifdef CONFIG_NET_CLS_ACT
1172 static int __stmmac_test_l3filt(struct stmmac_priv *priv, u32 dst, u32 src,
1173 u32 dst_mask, u32 src_mask)
1174 {
1175 struct flow_dissector_key_ipv4_addrs key, mask;
1176 unsigned long dummy_cookie = 0xdeadbeef;
1177 struct flow_dissector dissector = { };
1178 struct stmmac_packet_attrs attr = { };
1179 struct flow_cls_offload cls = { };
1180 struct flow_rule *rule;
1181 int ret;
1182
1183 if (!tc_can_offload(priv->dev))
1184 return -EOPNOTSUPP;
1185 if (!priv->dma_cap.l3l4fnum)
1186 return -EOPNOTSUPP;
1187 if (priv->rss.enable) {
1188 struct stmmac_rss rss = { .enable = false, };
1189
1190 stmmac_rss_configure(priv, priv->hw, &rss,
1191 priv->plat->rx_queues_to_use);
1192 }
1193
1194 dissector.used_keys |= (1 << FLOW_DISSECTOR_KEY_IPV4_ADDRS);
1195 dissector.offset[FLOW_DISSECTOR_KEY_IPV4_ADDRS] = 0;
1196
1197 cls.common.chain_index = 0;
1198 cls.command = FLOW_CLS_REPLACE;
1199 cls.cookie = dummy_cookie;
1200
1201 rule = kzalloc(struct_size(rule, action.entries, 1), GFP_KERNEL);
1202 if (!rule) {
1203 ret = -ENOMEM;
1204 goto cleanup_rss;
1205 }
1206
1207 rule->match.dissector = &dissector;
1208 rule->match.key = (void *)&key;
1209 rule->match.mask = (void *)&mask;
1210
1211 key.src = htonl(src);
1212 key.dst = htonl(dst);
1213 mask.src = src_mask;
1214 mask.dst = dst_mask;
1215
1216 cls.rule = rule;
1217
1218 rule->action.entries[0].id = FLOW_ACTION_DROP;
1219 rule->action.num_entries = 1;
1220
1221 attr.dst = priv->dev->dev_addr;
1222 attr.ip_dst = dst;
1223 attr.ip_src = src;
1224
1225 /* Shall receive packet */
1226 ret = __stmmac_test_loopback(priv, &attr);
1227 if (ret)
1228 goto cleanup_rule;
1229
1230 ret = stmmac_tc_setup_cls(priv, priv, &cls);
1231 if (ret)
1232 goto cleanup_rule;
1233
1234 /* Shall NOT receive packet */
1235 ret = __stmmac_test_loopback(priv, &attr);
1236 ret = ret ? 0 : -EINVAL;
1237
1238 cls.command = FLOW_CLS_DESTROY;
1239 stmmac_tc_setup_cls(priv, priv, &cls);
1240 cleanup_rule:
1241 kfree(rule);
1242 cleanup_rss:
1243 if (priv->rss.enable) {
1244 stmmac_rss_configure(priv, priv->hw, &priv->rss,
1245 priv->plat->rx_queues_to_use);
1246 }
1247
1248 return ret;
> 1249 }
1250 #else
1251 static int __stmmac_test_l3filt(struct stmmac_priv *priv, u32 dst, u32 src,
1252 u32 dst_mask, u32 src_mask)
1253 {
1254 return -EOPNOTSUPP;
1255 }
1256 #endif
1257
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
PATCH 6/13 net: stmmac: xgmac: Implement ARP Offload
In reply to Jose AbreuImplement the ARP Offload feature in XGMAC 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/common.h | 1 + drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 17 +++++++++++++++++ drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c | 1 + drivers/net/ethernet/stmicro/stmmac/hwif.h | 3 +++ 4 files changed, 22 insertions(+)
drivers/net/ethernet/stmicro/stmmac/common.h +1 -0
@@ -361,6 +361,7 @@ struct dma_features {unsigned int vlins;unsigned int dvlan;unsigned int l3l4fnum; +unsigned int arpoffsel; };/* GMAC TX FIFO is 8K, Rx FIFO is 16K */
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +17 -0
@@ -1338,6 +1338,22 @@ static int dwxgmac2_config_l4_filter(struct mac_device_info *hw, u32 filter_no,return 0 ; } +static void dwxgmac2_set_arp_offload (struct mac_device_info *hw,bool en, +u32 addr) +{ +void __iomem *ioaddr = hw->pcsr; +u32 value; + +writel (addr, ioaddr +XGMAC_ARP_ADDR ); + + value =readl (ioaddr +XGMAC_RX_CONFIG ); +if (en) + value |=XGMAC_CONFIG_ARPEN ; +else + value &= ~XGMAC_CONFIG_ARPEN ; +writel (value, ioaddr +XGMAC_RX_CONFIG ); +} +const struct stmmac_ops dwxgmac210_ops = { .core_init = dwxgmac2_core_init, .set_mac = dwxgmac2_set_mac,
@@ -1380,6 +1396,7 @@ const struct stmmac_ops dwxgmac210_ops = { .enable_vlan = dwxgmac2_enable_vlan, .config_l3_filter = dwxgmac2_config_l3_filter, .config_l4_filter = dwxgmac2_config_l4_filter, + .set_arp_offload = dwxgmac2_set_arp_offload, };int dwxgmac2_setup (struct stmmac_priv *priv)
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c +1 -0
@@ -370,6 +370,7 @@ static void dwxgmac2_get_hw_feature(void __iomem *ioaddr, dma_cap->atime_stamp = (hw_cap &XGMAC_HWFEAT_TSSEL ) >>12 ; dma_cap->av = (hw_cap &XGMAC_HWFEAT_AVSEL ) >>11 ; dma_cap->av &= (hw_cap &XGMAC_HWFEAT_RAVSEL ) >>10 ; + dma_cap->arpoffsel = (hw_cap &XGMAC_HWFEAT_ARPOFFSEL ) >>9 ; dma_cap->rmon = (hw_cap &XGMAC_HWFEAT_MMCSEL ) >>8 ; dma_cap->pmt_magic_frame = (hw_cap &XGMAC_HWFEAT_MGKSEL ) >>7 ; dma_cap->pmt_remote_wake_up = (hw_cap &XGMAC_HWFEAT_RWKSEL ) >>6 ;
drivers/net/ethernet/stmicro/stmmac/hwif.h +3 -0
@@ -370,6 +370,7 @@ struct stmmac_ops {int (*config_l4_filter)(struct mac_device_info *hw,u32 filter_no,bool en,bool udp,bool sa,bool inv,u32 match); +void (*set_arp_offload)(struct mac_device_info *hw,bool en,u32 addr); }; #define stmmac_core_init(__priv, __args...) \
@@ -454,6 +455,8 @@ struct stmmac_ops { stmmac_do_callback(__priv, mac, config_l3_filter, __args) #define stmmac_config_l4_filter(__priv, __args...) \ stmmac_do_callback(__priv, mac, config_l4_filter, __args) +#define stmmac_set_arp_offload(__priv, __args...) \ + stmmac_do_void_callback(__priv, mac, set_arp_offload, __args)/* PTP and HW Timer helpers */ struct stmmac_hwtimestamp {
Signature · 1 line
2.7.4
PATCH 7/13 net: stmmac: selftests: Implement the ARP Offload test
In reply to Jose AbreuImplement a test for ARP Offload feature.
---
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 | 110 +++++++++++++++++++++ 1 file changed, 110 insertions(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +110 -0
@@ -196,6 +196,24 @@ static struct sk_buff *stmmac_test_get_udp_skb(struct stmmac_priv *priv,return skb; } +static struct sk_buff *stmmac_test_get_arp_skb (struct stmmac_priv *priv, +struct stmmac_packet_attrs *attr) +{ +__be32 ip_src =htonl (attr->ip_src); +__be32 ip_dst =htonl (attr->ip_dst); +struct sk_buff *skb =NULL ; + + skb =arp_create (ARPOP_REQUEST ,ETH_P_ARP , ip_dst, priv->dev, ip_src, +NULL , attr->src, attr->dst); +if (!skb) +return NULL ; + + skb->pkt_type =PACKET_HOST ; + skb->dev = priv->dev; + +return skb; +} +struct stmmac_test_priv {struct stmmac_packet_attrs *packet;struct packet_type pt;
@@ -1396,6 +1414,94 @@ static int stmmac_test_l4filt_sa_udp(struct stmmac_priv *priv)return __stmmac_test_l4filt (priv,0 , dummy_port,0 , ~0 , true); } +static int stmmac_test_arp_validate (struct sk_buff *skb, +struct net_device *ndev, +struct packet_type *pt, +struct net_device *orig_ndev) +{ +struct stmmac_test_priv *tpriv = pt->af_packet_priv; +struct ethhdr *ehdr; +struct arphdr *ahdr; + + ehdr = (struct ethhdr *)skb_mac_header (skb); +if (!ether_addr_equal (ehdr->h_dest, tpriv->packet->src)) + goto out; + + ahdr =arp_hdr (skb); +if (ahdr->ar_op !=htons (ARPOP_REPLY )) + goto out; + + tpriv->ok = true; +complete (&tpriv->comp); +out: +kfree_skb (skb); +return 0 ; +} + +static int stmmac_test_arpoffload (struct stmmac_priv *priv) +{ +unsigned char src[ETH_ALEN ] = {0x01 ,0x02 ,0x03 ,0x04 ,0x05 ,0x06 }; +unsigned char dst[ETH_ALEN ] = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }; +struct stmmac_packet_attrs attr = { }; +struct stmmac_test_priv *tpriv; +struct sk_buff *skb =NULL ; +u32 ip_addr =0xdeadcafe ; +u32 ip_src =0xdeadbeef ; +int ret; + +if (!priv->dma_cap.arpoffsel) +return -EOPNOTSUPP ; + + tpriv =kzalloc (sizeof (*tpriv),GFP_KERNEL ); +if (!tpriv) +return -ENOMEM ; + + tpriv->ok = false; +init_completion (&tpriv->comp); + + tpriv->pt.type =htons (ETH_P_ARP ); + tpriv->pt.func = stmmac_test_arp_validate; + tpriv->pt.dev = priv->dev; + tpriv->pt.af_packet_priv = tpriv; + tpriv->packet = &attr; +dev_add_pack (&tpriv->pt); + + attr.src = src; + attr.ip_src = ip_src; + attr.dst = dst; + attr.ip_dst = ip_addr; + + skb =stmmac_test_get_arp_skb (priv, &attr); +if (!skb) { + ret = -ENOMEM ; + goto cleanup; + } + + ret =stmmac_set_arp_offload (priv, priv->hw, true, ip_addr); +if (ret) + goto cleanup; + + ret =dev_set_promiscuity (priv->dev,1 ); +if (ret) + goto cleanup; + +skb_set_queue_mapping (skb,0 ); + ret =dev_queue_xmit (skb); +if (ret) + goto cleanup_promisc; + +wait_for_completion_timeout (&tpriv->comp,STMMAC_LB_TIMEOUT ); + ret = tpriv->ok ?0 : -ETIMEDOUT ; + +cleanup_promisc: +dev_set_promiscuity (priv->dev,-1 ); +cleanup: +stmmac_set_arp_offload (priv, priv->hw, false,0x0 ); +dev_remove_pack (&tpriv->pt); +kfree (tpriv); +return ret; +} +#define STMMAC_LOOPBACK_NONE 0#define STMMAC_LOOPBACK_MAC 1#define STMMAC_LOOPBACK_PHY 2
@@ -1505,6 +1611,10 @@ static const struct stmmac_test { .name = "L4 SA UDP Filtering ", .lb = STMMAC_LOOPBACK_PHY, .fn = stmmac_test_l4filt_sa_udp, + }, { + .name = "ARP Offload ", + .lb = STMMAC_LOOPBACK_PHY, + .fn = stmmac_test_arpoffload, }, };
Signature · 1 line
2.7.4
PATCH 8/13 net: stmmac: Only consider RX error when HW Timestamping is not enabled
In reply to Jose AbreuOnly consider that we have an error when HW Timestamping is not enabled as this can give false positives due to the fact the RX Timestamping in XGMAC and GMAC cores comes from context descriptors.
---
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/stmmac_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -1
@@ -3511,9 +3511,10 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue) &priv->xstats, rx_q->dma_erx + entry);if (unlikely (status == discard_frame)) {page_pool_recycle_direct (rx_q->page_pool, buf->page); - priv->dev->stats.rx_errors++; buf->page =NULL ; error =1 ; +if (!priv->hwts_rx_en) + priv->dev->stats.rx_errors++; }if (unlikely (error && (status & rx_not_ls)))
Signature · 1 line
2.7.4
PATCH 9/13 net: stmmac: ethtool: Let user configure TX coalesce without RIWT
In reply to Jose AbreuWhen RX Watchdog is disabled its currently not possible to configure TX coalesce settings. Let user configure it anyway.
---
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_ethtool.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +9 -12
@@ -746,8 +746,15 @@ static int stmmac_set_coalesce(struct net_device *dev, (ec->tx_max_coalesced_frames_high) || (ec->rate_sample_interval))return -EOPNOTSUPP ; -if (ec->rx_coalesce_usecs ==0 ) -return -EINVAL ; +if (priv->use_riwt && (ec->rx_coalesce_usecs >0 )) { + rx_riwt =stmmac_usec2riwt (ec->rx_coalesce_usecs, priv); + +if ((rx_riwt >MAX_DMA_RIWT ) || (rx_riwt <MIN_DMA_RIWT )) +return -EINVAL ; + + priv->rx_riwt = rx_riwt; +stmmac_rx_watchdog (priv, priv->ioaddr, priv->rx_riwt, rx_cnt); + }if ((ec->tx_coalesce_usecs ==0 ) && (ec->tx_max_coalesced_frames ==0 ))
@@ -757,20 +764,10 @@ static int stmmac_set_coalesce(struct net_device *dev, (ec->tx_max_coalesced_frames > STMMAC_TX_MAX_FRAMES)) return -EINVAL; - rx_riwt =stmmac_usec2riwt (ec->rx_coalesce_usecs, priv); - -if ((rx_riwt >MAX_DMA_RIWT ) || (rx_riwt <MIN_DMA_RIWT )) -return -EINVAL ; -else if (!priv->use_riwt) -return -EOPNOTSUPP ; -/* Only copy relevant parameters, ignore all others. */ priv->tx_coal_frames = ec->tx_max_coalesced_frames; priv->tx_coal_timer = ec->tx_coalesce_usecs; priv->rx_coal_frames = ec->rx_max_coalesced_frames; - priv->rx_riwt = rx_riwt; -stmmac_rx_watchdog (priv, priv->ioaddr, priv->rx_riwt, rx_cnt); -return 0 ; }
Signature · 1 line
2.7.4
PATCH 10/13 net: stmmac: xgmac: Correct RAVSEL field interpretation
In reply to Jose AbreuRAVSEL means that only RX side is available for AVB features. As we use both TX and RX features we need to check if RAVSEL is selected and disable AVB if only RX side is available.
---
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/dwxgmac2_dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c +1 -1
@@ -369,7 +369,7 @@ static void dwxgmac2_get_hw_feature(void __iomem *ioaddr, dma_cap->eee = (hw_cap &XGMAC_HWFEAT_EEESEL ) >>13 ; dma_cap->atime_stamp = (hw_cap &XGMAC_HWFEAT_TSSEL ) >>12 ; dma_cap->av = (hw_cap &XGMAC_HWFEAT_AVSEL ) >>11 ; - dma_cap->av &= (hw_cap &XGMAC_HWFEAT_RAVSEL ) >>10 ; + dma_cap->av &= !(hw_cap &XGMAC_HWFEAT_RAVSEL ) >>10 ; dma_cap->arpoffsel = (hw_cap &XGMAC_HWFEAT_ARPOFFSEL ) >>9 ; dma_cap->rmon = (hw_cap &XGMAC_HWFEAT_MMCSEL ) >>8 ; dma_cap->pmt_magic_frame = (hw_cap &XGMAC_HWFEAT_MGKSEL ) >>7 ;
Signature · 1 line
2.7.4
PATCH 11/13 net: stmmac: Correctly assing MAX MTU in XGMAC cores case
In reply to Jose AbreuMaximum MTU for XGMAC cores is 16k thus the check for presence of XGMAC shall be done first in order to assign correct value.
---
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/stmmac_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +3 -3
@@ -4542,10 +4542,10 @@ int stmmac_dvr_probe(struct device *device,/* MTU range: 46 - hw-specific max */ ndev->min_mtu =ETH_ZLEN -ETH_HLEN ; -if ((priv->plat->enh_desc) || (priv->synopsys_id >=DWMAC_CORE_4_00 )) - ndev->max_mtu =JUMBO_LEN ; -else if (priv->plat->has_xgmac) +if (priv->plat->has_xgmac) ndev->max_mtu =XGMAC_JUMBO_LEN ; +else if ((priv->plat->enh_desc) || (priv->synopsys_id >=DWMAC_CORE_4_00 )) + ndev->max_mtu =JUMBO_LEN ;else ndev->max_mtu =SKB_MAX_HEAD (NET_SKB_PAD +NET_IP_ALIGN );/* Will not overwrite ndev->max_mtu if plat->maxmtu > ndev->max_mtu
Signature · 1 line
2.7.4
PATCH 12/13 net: stmmac: xgmac: Enable RX Jumbo frame support
In reply to Jose AbreuWe are already doing it by default in the TX path so we can also enable Jumbo Frame support in the RX path independently of MTU value.
---
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/dwxgmac2.h | 3 ++- drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 11 ----------- 2 files changed, 2 insertions(+), 12 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h +2 -1
@@ -44,7 +44,8 @@#define XGMAC_CONFIG_CST BIT(2)#define XGMAC_CONFIG_ACS BIT(1)#define XGMAC_CONFIG_RE BIT(0) -#define XGMAC_CORE_INIT_RX 0 +#define XGMAC_CORE_INIT_RX (XGMAC_CONFIG_GPSLCE | XGMAC_CONFIG_WD | \ + (XGMAC_JUMBO_LEN << XGMAC_CONFIG_GPSL_SHIFT))#define XGMAC_PACKET_FILTER 0x00000008#define XGMAC_FILTER_RA BIT(31)#define XGMAC_FILTER_IPFE BIT(20)
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +0 -11
@@ -15,7 +15,6 @@ static void dwxgmac2_core_init(struct mac_device_info *hw, struct net_device *dev) {void __iomem *ioaddr = hw->pcsr; -int mtu = dev->mtu;u32 tx, rx; tx =readl (ioaddr +XGMAC_TX_CONFIG );
@@ -24,16 +23,6 @@ static void dwxgmac2_core_init(struct mac_device_info *hw, tx |=XGMAC_CORE_INIT_TX ; rx |=XGMAC_CORE_INIT_RX ; -if (mtu >=9000 ) { - rx |=XGMAC_CONFIG_GPSLCE ; - rx |=XGMAC_JUMBO_LEN <<XGMAC_CONFIG_GPSL_SHIFT ; - rx |=XGMAC_CONFIG_WD ; - }else if (mtu >2000 ) { - rx |=XGMAC_CONFIG_JE ; - }else if (mtu >1500 ) { - rx |=XGMAC_CONFIG_S2KP ; - } -if (hw->ps) { tx |=XGMAC_CONFIG_TE ; tx &= ~hw->link.speed_mask;
Signature · 7 lines
2.7.4 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 13/13 net: stmmac: selftests: Add Jumbo Frame tests
In reply to Jose AbreuAdd a test to validate the Jumbo Frame support in stmmac in single channel and multichannel mode.
---
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 | 65 +++++++++++++++++++++- 1 file changed, 62 insertions(+), 3 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +62 -3
@@ -43,9 +43,11 @@ struct stmmac_packet_attrs {int dont_wait;int timeout;int size; +int max_size;int remove_sa;u8 id;int sarc; +u16 queue_mapping; };static u8 stmmac_test_next_id;
@@ -73,12 +75,14 @@ static struct sk_buff *stmmac_test_get_udp_skb(struct stmmac_priv *priv,else size +=sizeof (struct udphdr ); - skb =netdev_alloc_skb (priv->dev, size); +if (attr->max_size && (attr->max_size > size)) + size = attr->max_size; + + skb =netdev_alloc_skb_ip_align (priv->dev, size);if (!skb)return NULL ;prefetchw (skb->data); -skb_reserve (skb,NET_IP_ALIGN );if (attr->vlan >1 ) ehdr =skb_push (skb,ETH_HLEN +8 );
@@ -147,6 +151,9 @@ static struct sk_buff *stmmac_test_get_udp_skb(struct stmmac_priv *priv, uhdr->source =htons (attr->sport); uhdr->dest =htons (attr->dport); uhdr->len =htons (sizeof (*shdr) +sizeof (*uhdr) + attr->size); +if (attr->max_size) + uhdr->len =htons (attr->max_size - + (sizeof (*ihdr) +sizeof (*ehdr))); uhdr->check =0 ; }
@@ -162,6 +169,10 @@ static struct sk_buff *stmmac_test_get_udp_skb(struct stmmac_priv *priv, iplen +=sizeof (*thdr); else iplen += sizeof(*uhdr); + +if (attr->max_size) + iplen = attr->max_size -sizeof (*ehdr); + ihdr->tot_len =htons (iplen); ihdr->frag_off =0 ; ihdr->saddr =htonl (attr->ip_src);
@@ -178,6 +189,8 @@ static struct sk_buff *stmmac_test_get_udp_skb(struct stmmac_priv *priv,if (attr->size)skb_put (skb, attr->size); +if (attr->max_size && (attr->max_size > skb->len)) +skb_put (skb, attr->max_size - skb->len); skb->csum =0 ; skb->ip_summed =CHECKSUM_PARTIAL ;
@@ -324,7 +337,7 @@ static int __stmmac_test_loopback(struct stmmac_priv *priv, goto cleanup; } -skb_set_queue_mapping (skb,0 ); +skb_set_queue_mapping (skb, attr->queue_mapping); ret =dev_queue_xmit (skb);if (ret) goto cleanup;
@@ -1502,6 +1515,44 @@ static int stmmac_test_arpoffload(struct stmmac_priv *priv)return ret; } +static int __stmmac_test_jumbo (struct stmmac_priv *priv,u16 queue) +{ +struct stmmac_packet_attrs attr = { }; +int size = priv->dma_buf_sz; + +/* Only XGMAC has SW support for multiple RX descs in same packet */ +if (priv->plat->has_xgmac) + size = priv->dev->max_mtu; + + attr.dst = priv->dev->dev_addr; + attr.max_size = size -ETH_FCS_LEN ; + attr.queue_mapping = queue; + +return __stmmac_test_loopback (priv, &attr); +} + +static int stmmac_test_jumbo (struct stmmac_priv *priv) +{ +return __stmmac_test_jumbo (priv,0 ); +} + +static int stmmac_test_mjumbo (struct stmmac_priv *priv) +{ +u32 chan, tx_cnt = priv->plat->tx_queues_to_use; +int ret; + +if (tx_cnt <=1 ) +return -EOPNOTSUPP ; + +for (chan =0 ; chan < tx_cnt; chan++) { + ret =__stmmac_test_jumbo (priv, chan); +if (ret) +return ret; + } + +return 0 ; +} +#define STMMAC_LOOPBACK_NONE 0#define STMMAC_LOOPBACK_MAC 1#define STMMAC_LOOPBACK_PHY 2
@@ -1615,6 +1666,14 @@ static const struct stmmac_test { .name = "ARP Offload ", .lb = STMMAC_LOOPBACK_PHY, .fn = stmmac_test_arpoffload, + }, { + .name = "Jumbo Frame ", + .lb = STMMAC_LOOPBACK_PHY, + .fn = stmmac_test_jumbo, + }, { + .name = "Multichannel Jumbo ", + .lb = STMMAC_LOOPBACK_PHY, + .fn = stmmac_test_mjumbo, }, };
Signature · 1 line
2.7.4