From: Roger Quadros <rogerq@kernel.org> Date: 2023-12-01 13:58:15
Handle offloading commands using switch-case in
am65_cpsw_setup_taprio().
Move checks to am65_cpsw_taprio_replace().
Use NL_SET_ERR_MSG_MOD for error messages.
Change error message from "Failed to set cycle time extension"
to "cycle time extension not supported"
Signed-off-by: Roger Quadros <rogerq@kernel.org>
---
drivers/net/ethernet/ti/am65-cpsw-qos.c | 149 +++++++++++-------------
1 file changed, 70 insertions(+), 79 deletions(-)
Changelog
v7: don't use "\n" in NL_SET_ERR_MSG_MOD()
v6: initial commit
@@ -441,29 +441,66 @@ static void am65_cpsw_purge_est(struct net_device *ndev)port->qos.est_admin=NULL;}-staticintam65_cpsw_configure_taprio(structnet_device*ndev,-structam65_cpsw_est*est_new)+staticvoidam65_cpsw_cp_taprio(structtc_taprio_qopt_offload*from,+structtc_taprio_qopt_offload*to)+{+inti;++*to=*from;+for(i=0;i<from->num_entries;i++)+to->entries[i]=from->entries[i];+}++staticintam65_cpsw_taprio_replace(structnet_device*ndev,+structtc_taprio_qopt_offload*taprio){structam65_cpsw_common*common=am65_ndev_to_common(ndev);+structnetlink_ext_ack*extack=taprio->mqprio.extack;+structam65_cpsw_port*port=am65_ndev_to_port(ndev);structam65_cpts*cpts=common->cpts;intret=0,tact=TACT_PROG;+structam65_cpsw_est*est_new;-am65_cpsw_est_update_state(ndev);+if(!netif_running(ndev)){+NL_SET_ERR_MSG_MOD(extack,"interface is down, link speed unknown");+return-ENETDOWN;+}-if(est_new->taprio.cmd==TAPRIO_CMD_DESTROY){-am65_cpsw_stop_est(ndev);-returnret;+if(common->pf_p0_rx_ptype_rrobin){+NL_SET_ERR_MSG_MOD(extack,+"p0-rx-ptype-rrobin flag conflicts with taprio qdisc");+return-EINVAL;+}++if(port->qos.link_speed==SPEED_UNKNOWN)+return-ENOLINK;++if(taprio->cycle_time_extension){+NL_SET_ERR_MSG_MOD(extack,+"cycle time extension not supported");+return-EOPNOTSUPP;}+est_new=devm_kzalloc(&ndev->dev,+struct_size(est_new,taprio.entries,taprio->num_entries),+GFP_KERNEL);+if(!est_new)+return-ENOMEM;++am65_cpsw_cp_taprio(taprio,&est_new->taprio);++am65_cpsw_est_update_state(ndev);+ret=am65_cpsw_est_check_scheds(ndev,est_new);if(ret<0)-returnret;+gotofail;tact=am65_cpsw_timer_act(ndev,est_new);if(tact==TACT_NEED_STOP){-dev_err(&ndev->dev,-"Can't toggle estf timer, stop taprio first");-return-EINVAL;+NL_SET_ERR_MSG_MOD(extack,+"Can't toggle estf timer, stop taprio first");+ret=-EINVAL;+gotofail;}if(tact==TACT_PROG)
@@ -476,62 +513,24 @@ static int am65_cpsw_configure_taprio(struct net_device *ndev,am65_cpsw_est_set_sched_list(ndev,est_new);am65_cpsw_port_est_assign_buf_num(ndev,est_new->buf);-am65_cpsw_est_set(ndev,est_new->taprio.cmd==TAPRIO_CMD_REPLACE);+am65_cpsw_est_set(ndev,1);if(tact==TACT_PROG){ret=am65_cpsw_timer_set(ndev,est_new);if(ret){-dev_err(&ndev->dev,"Failed to set cycle time");-returnret;+NL_SET_ERR_MSG_MOD(extack,+"Failed to set cycle time");+gotofail;}}-returnret;-}--staticvoidam65_cpsw_cp_taprio(structtc_taprio_qopt_offload*from,-structtc_taprio_qopt_offload*to)-{-inti;--*to=*from;-for(i=0;i<from->num_entries;i++)-to->entries[i]=from->entries[i];-}--staticintam65_cpsw_set_taprio(structnet_device*ndev,void*type_data)-{-structam65_cpsw_port*port=am65_ndev_to_port(ndev);-structtc_taprio_qopt_offload*taprio=type_data;-structam65_cpsw_est*est_new;-intret=0;--if(taprio->cycle_time_extension){-dev_err(&ndev->dev,"Failed to set cycle time extension");-return-EOPNOTSUPP;-}--est_new=devm_kzalloc(&ndev->dev,-struct_size(est_new,taprio.entries,taprio->num_entries),-GFP_KERNEL);-if(!est_new)-return-ENOMEM;--am65_cpsw_cp_taprio(taprio,&est_new->taprio);-ret=am65_cpsw_configure_taprio(ndev,est_new);-if(!ret){-if(taprio->cmd==TAPRIO_CMD_REPLACE){-devm_kfree(&ndev->dev,port->qos.est_admin);+devm_kfree(&ndev->dev,port->qos.est_admin);+port->qos.est_admin=est_new;-port->qos.est_admin=est_new;-}else{-devm_kfree(&ndev->dev,est_new);-am65_cpsw_purge_est(ndev);-}-}else{-devm_kfree(&ndev->dev,est_new);-}+return0;+fail:+devm_kfree(&ndev->dev,est_new);returnret;}
@@ -558,34 +557,26 @@ static void am65_cpsw_est_link_up(struct net_device *ndev, int link_speed)return;purge_est:-am65_cpsw_purge_est(ndev);+am65_cpsw_taprio_destroy(ndev);}staticintam65_cpsw_setup_taprio(structnet_device*ndev,void*type_data){-structam65_cpsw_port*port=am65_ndev_to_port(ndev);structtc_taprio_qopt_offload*taprio=type_data;-structam65_cpsw_common*common=port->common;--if(taprio->cmd!=TAPRIO_CMD_REPLACE&&-taprio->cmd!=TAPRIO_CMD_DESTROY)-return-EOPNOTSUPP;--if(!netif_running(ndev)){-dev_err(&ndev->dev,"interface is down, link speed unknown\n");-return-ENETDOWN;-}--if(common->pf_p0_rx_ptype_rrobin){-dev_err(&ndev->dev,-"p0-rx-ptype-rrobin flag conflicts with taprio qdisc\n");-return-EINVAL;+interr=0;++switch(taprio->cmd){+caseTAPRIO_CMD_REPLACE:+err=am65_cpsw_taprio_replace(ndev,taprio);+break;+caseTAPRIO_CMD_DESTROY:+am65_cpsw_taprio_destroy(ndev);+break;+default:+err=-EOPNOTSUPP;}-if(port->qos.link_speed==SPEED_UNKNOWN)-return-ENOLINK;--returnam65_cpsw_set_taprio(ndev,type_data);+returnerr;}staticintam65_cpsw_tc_query_caps(structnet_device*ndev,void*type_data)
From: Roger Quadros <rogerq@kernel.org> Date: 2023-12-01 13:58:19
Move this code to the end to avoid forward declaration.
No functional change.
Signed-off-by: Roger Quadros <rogerq@kernel.org>
---
drivers/net/ethernet/ti/am65-cpsw-qos.c | 86 ++++++++++++-------------
1 file changed, 43 insertions(+), 43 deletions(-)
Changelog
v7: move am65_cpsw_qos_tx_rate_calc()
v6: no change
v5: no change
v4: initial commit
@@ -56,6 +56,16 @@ enum timer_act {TACT_SKIP_PROG,/* just buffer can be updated */};+staticu32+am65_cpsw_qos_tx_rate_calc(u32rate_mbps,unsignedlongbus_freq)+{+u32ir;++bus_freq/=1000000;+ir=DIV_ROUND_UP(((u64)rate_mbps*32768),bus_freq);+returnir;+}+staticintam65_cpsw_port_est_enabled(structam65_cpsw_port*port){returnport->qos.est_oper||port->qos.est_admin;
From: Roger Quadros <rogerq@kernel.org> Date: 2023-12-01 13:58:26
From: Grygorii Strashko <grygorii.strashko@ti.com>
This patch adds MQPRIO Qdisc offload in full 'channel' mode which allows
not only setting up pri:tc mapping, but also configuring TX shapers
(rate-limiting) on external port FIFOs.
The MQPRIO Qdisc offload is expected to work with or without VLAN/priority
tagged packets.
The CPSW external Port FIFO has 8 Priority queues. The rate-limit can be
set for each of these priority queues. Which Priority queue a packet is
assigned to depends on PN_REG_TX_PRI_MAP register which maps header
priority to switch priority.
The header priority of a packet is assigned via the RX_PRI_MAP_REG which
maps packet priority to header priority.
The packet priority is either the VLAN priority (for VLAN tagged packets)
or the thread/channel offset.
For simplicity, we assign the same priority queue to all queues of a
Traffic Class so it can be rate-limited correctly.
Configuration example:
ethtool -L eth1 tx 5
ethtool --set-priv-flags eth1 p0-rx-ptype-rrobin off
tc qdisc add dev eth1 parent root handle 100: mqprio num_tc 3 \
map 0 0 1 2 0 0 0 0 0 0 0 0 0 0 0 0 \
queues 1@0 1@1 1@2 hw 1 mode channel \
shaper bw_rlimit min_rate 0 100mbit 200mbit max_rate 0 101mbit 202mbit
tc qdisc replace dev eth2 handle 100: parent root mqprio num_tc 1 \
map 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 queues 1@0 hw 1
ip link add link eth1 name eth1.100 type vlan id 100
ip link set eth1.100 type vlan egress 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7
In the above example two ports share the same TX CPPI queue 0 for low
priority traffic. 3 traffic classes are defined for eth1 and mapped to:
TC0 - low priority, TX CPPI queue 0 -> ext Port 1 fifo0, no rate limit
TC1 - prio 2, TX CPPI queue 1 -> ext Port 1 fifo1, CIR=100Mbit/s, EIR=1Mbit/s
TC2 - prio 3, TX CPPI queue 2 -> ext Port 1 fifo2, CIR=200Mbit/s, EIR=2Mbit/s
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Roger Quadros <rogerq@kernel.org>
---
drivers/net/ethernet/ti/am65-cpsw-nuss.c | 3 +
drivers/net/ethernet/ti/am65-cpsw-qos.c | 254 ++++++++++++++++++++++-
drivers/net/ethernet/ti/am65-cpsw-qos.h | 20 ++
3 files changed, 274 insertions(+), 3 deletions(-)
Changelog
v7:
- don't return -EINVAL if num_tc is 0 in setup
v6:
- fixed typo in comment "packet_priorit"->"packet_priority"
- don't call netif_set_real_num_tx_queues() from am65_cpsw_reset_tc_mqprio()
- reset TX queue priorities to zero at init. AM65_CPSW_PN_REG_TX_PRI_MAP = 0
- don't ignore return value in am65_cpsw_setup_mqprio()
v5:
- fix warning at NL_SET_ERR_MSG_FMT_MOD()
v4:
- use macro TO_MBPS()
- use bool for 'shaper_en'
- split code movement into separate patch
- drop rate vs link speed check as mqprio can be set at link down
- call am65_cpsw_reset_tc_mqprio() after pm_runtime_get_sync()
v2:
- clean up commit message
- avoid forward declarations
- use tc_mqprio_qopt_offload :: extack for error message reporting
- avoid unnecessary mqprio->qopt.hw == 0 checks
- set struct tc_mqprio_caps :: validate_queue_counts = true and get rid of
am65_cpsw_mqprio_verify()
- do not modify AM65_CPSW_P0_REG_RX_PRI_MAP register.
@@ -2127,6 +2127,9 @@ static int am65_cpsw_nuss_init_slave_ports(struct am65_cpsw_common *common)dev_err(dev,"Use random MAC address\n");}}++/* Reset all Queue priorities to 0 */+writel(0,port->port_base+AM65_CPSW_PN_REG_TX_PRI_MAP);}of_node_put(node);
@@ -15,6 +15,8 @@#include"am65-cpts.h"#include"cpsw_ale.h"+#define TO_MBPS(x) ((x) * 8 / 1000000)+enumtimer_act{TACT_PROG,/* need program timer */TACT_NEED_STOP,/* need stop first */
@@ -31,6 +33,232 @@ am65_cpsw_qos_tx_rate_calc(u32 rate_mbps, unsigned long bus_freq)returnir;}+staticvoidam65_cpsw_tx_pn_shaper_reset(structam65_cpsw_port*port)+{+intprio;++for(prio=0;prio<AM65_CPSW_PN_FIFO_PRIO_NUM;prio++){+writel(0,port->port_base+AM65_CPSW_PN_REG_PRI_CIR(prio));+writel(0,port->port_base+AM65_CPSW_PN_REG_PRI_EIR(prio));+}+}++staticvoidam65_cpsw_tx_pn_shaper_apply(structam65_cpsw_port*port)+{+structam65_cpsw_mqprio*p_mqprio=&port->qos.mqprio;+structam65_cpsw_common*common=port->common;+structtc_mqprio_qopt_offload*mqprio;+boolenable,shaper_susp=false;+u32rate_mbps;+inttc,prio;++mqprio=&p_mqprio->mqprio_hw;+/* takes care of no link case as well */+if(p_mqprio->max_rate_total>port->qos.link_speed)+shaper_susp=true;++am65_cpsw_tx_pn_shaper_reset(port);++enable=p_mqprio->shaper_en&&!shaper_susp;+if(!enable)+return;++/* Rate limit is specified per Traffic Class but+*forCPSW,ratelimitcanbeappliedperpriority+*atportFIFO.+*+*Wehaveassignedthesamepriority(TCn)toallqueues+*ofaTrafficClasssotheysharethesameshaper+*bandwidth.+*/+for(tc=0;tc<mqprio->qopt.num_tc;tc++){+prio=tc;++rate_mbps=TO_MBPS(mqprio->min_rate[tc]);+rate_mbps=am65_cpsw_qos_tx_rate_calc(rate_mbps,+common->bus_freq);+writel(rate_mbps,+port->port_base+AM65_CPSW_PN_REG_PRI_CIR(prio));++rate_mbps=0;++if(mqprio->max_rate[tc]){+rate_mbps=mqprio->max_rate[tc]-mqprio->min_rate[tc];+rate_mbps=TO_MBPS(rate_mbps);+rate_mbps=am65_cpsw_qos_tx_rate_calc(rate_mbps,+common->bus_freq);+}++writel(rate_mbps,+port->port_base+AM65_CPSW_PN_REG_PRI_EIR(prio));+}+}++staticintam65_cpsw_mqprio_verify_shaper(structam65_cpsw_port*port,+structtc_mqprio_qopt_offload*mqprio)+{+structam65_cpsw_mqprio*p_mqprio=&port->qos.mqprio;+structnetlink_ext_ack*extack=mqprio->extack;+u64min_rate_total=0,max_rate_total=0;+u32min_rate_msk=0,max_rate_msk=0;+boolhas_min_rate,has_max_rate;+intnum_tc,i;++if(!(mqprio->flags&TC_MQPRIO_F_SHAPER))+return0;++if(mqprio->shaper!=TC_MQPRIO_SHAPER_BW_RATE)+return0;++has_min_rate=!!(mqprio->flags&TC_MQPRIO_F_MIN_RATE);+has_max_rate=!!(mqprio->flags&TC_MQPRIO_F_MAX_RATE);++if(!has_min_rate&&has_max_rate){+NL_SET_ERR_MSG_MOD(extack,"min_rate is required with max_rate");+return-EOPNOTSUPP;+}++if(!has_min_rate)+return0;++num_tc=mqprio->qopt.num_tc;++for(i=num_tc-1;i>=0;i--){+u32ch_msk;++if(mqprio->min_rate[i])+min_rate_msk|=BIT(i);+min_rate_total+=mqprio->min_rate[i];++if(has_max_rate){+if(mqprio->max_rate[i])+max_rate_msk|=BIT(i);+max_rate_total+=mqprio->max_rate[i];++if(!mqprio->min_rate[i]&&mqprio->max_rate[i]){+NL_SET_ERR_MSG_FMT_MOD(extack,+"TX tc%d rate max>0 but min=0\n",+i);+return-EINVAL;+}++if(mqprio->max_rate[i]&&+mqprio->max_rate[i]<mqprio->min_rate[i]){+NL_SET_ERR_MSG_FMT_MOD(extack,+"TX tc%d rate min(%llu)>max(%llu)\n",+i,mqprio->min_rate[i],+mqprio->max_rate[i]);+return-EINVAL;+}+}++ch_msk=GENMASK(num_tc-1,i);+if((min_rate_msk&BIT(i))&&(min_rate_msk^ch_msk)){+NL_SET_ERR_MSG_FMT_MOD(extack,+"Min rate must be set sequentially hi->lo tx_rate_msk%x\n",+min_rate_msk);+return-EINVAL;+}++if((max_rate_msk&BIT(i))&&(max_rate_msk^ch_msk)){+NL_SET_ERR_MSG_FMT_MOD(extack,+"Max rate must be set sequentially hi->lo tx_rate_msk%x\n",+max_rate_msk);+return-EINVAL;+}+}++min_rate_total=TO_MBPS(min_rate_total);+max_rate_total=TO_MBPS(max_rate_total);++p_mqprio->shaper_en=true;+p_mqprio->max_rate_total=max_t(u64,min_rate_total,max_rate_total);++return0;+}++staticvoidam65_cpsw_reset_tc_mqprio(structnet_device*ndev)+{+structam65_cpsw_port*port=am65_ndev_to_port(ndev);+structam65_cpsw_mqprio*p_mqprio=&port->qos.mqprio;++p_mqprio->shaper_en=false;+p_mqprio->max_rate_total=0;++am65_cpsw_tx_pn_shaper_reset(port);+netdev_reset_tc(ndev);++/* Reset all Queue priorities to 0 */+writel(0,port->port_base+AM65_CPSW_PN_REG_TX_PRI_MAP);+}++staticintam65_cpsw_setup_mqprio(structnet_device*ndev,void*type_data)+{+structam65_cpsw_port*port=am65_ndev_to_port(ndev);+structam65_cpsw_mqprio*p_mqprio=&port->qos.mqprio;+structtc_mqprio_qopt_offload*mqprio=type_data;+structam65_cpsw_common*common=port->common;+structtc_mqprio_qopt*qopt=&mqprio->qopt;+inti,tc,offset,count,prio,ret;+u8num_tc=qopt->num_tc;+u32tx_prio_map=0;++memcpy(&p_mqprio->mqprio_hw,mqprio,sizeof(*mqprio));++ret=pm_runtime_get_sync(common->dev);+if(ret<0){+pm_runtime_put_noidle(common->dev);+returnret;+}++if(!num_tc){+am65_cpsw_reset_tc_mqprio(ndev);+ret=0;+gotoexit_put;+}++ret=am65_cpsw_mqprio_verify_shaper(port,mqprio);+if(ret)+gotoexit_put;++netdev_set_num_tc(ndev,num_tc);++/* Multiple Linux priorities can map to a Traffic Class+*ATrafficClasscanhavemultiplecontiguousQueues,+*QueuesgetmappedtoChannels(thread_id),+*ifnotVLANtagged,thread_idisusedaspacket_priority+*ifVLANtagged.VLANpriorityisusedaspacket_priority+*packet_prioritygetsmappedtoheader_priorityinp0_rx_pri_map,+*header_prioritygetsmappedtoswitch_priorityinpn_tx_pri_map.+*Asp0_rx_pri_mapisleftatdefaults(0x76543210),wecan+*assumethatQueue_ngetsmappedtoheader_priority_n.Wecanthen+*settheswitchpriorityinpn_tx_pri_map.+*/++for(tc=0;tc<num_tc;tc++){+prio=tc;++/* For simplicity we assign the same priority (TCn) to+*allqueuesofaTrafficClass.+*/+for(i=qopt->offset[tc];i<qopt->offset[tc]+qopt->count[tc];i++)+tx_prio_map|=prio<<(4*i);++count=qopt->count[tc];+offset=qopt->offset[tc];+netdev_set_tc_queue(ndev,tc,count,offset);+}++writel(tx_prio_map,port->port_base+AM65_CPSW_PN_REG_TX_PRI_MAP);++am65_cpsw_tx_pn_shaper_apply(port);++exit_put:+pm_runtime_put(common->dev);++returnret;+}+staticintam65_cpsw_port_est_enabled(structam65_cpsw_port*port){returnport->qos.est_oper||port->qos.est_admin;
From: Roger Quadros <rogerq@kernel.org> Date: 2023-12-01 13:58:30
Add driver support for viewing / changing the MAC Merge sublayer
parameters and seeing the verification state machine's current state
via ethtool.
As hardware does not support interrupt notification for verification
events we resort to polling on link up. On link up we try a couple of
times for verification success and if unsuccessful then give up.
The Frame Preemption feature is described in the Technical Reference
Manual [1] in section:
12.3.1.4.6.7 Intersperced Express Traffic (IET – P802.3br/D2.0)
Due to Silicon Errata i2208 [2] we set limit min IET fragment size to 124.
[1] AM62x TRM - https://www.ti.com/lit/ug/spruiv7a/spruiv7a.pdf
[2] AM62x Silicon Errata - https://www.ti.com/lit/er/sprz487c/sprz487c.pdf
Signed-off-by: Roger Quadros <rogerq@kernel.org>
---
drivers/net/ethernet/ti/am65-cpsw-ethtool.c | 157 ++++++++++++++++++
drivers/net/ethernet/ti/am65-cpsw-nuss.c | 2 +
drivers/net/ethernet/ti/am65-cpsw-nuss.h | 5 +
drivers/net/ethernet/ti/am65-cpsw-qos.c | 175 ++++++++++++++++++++
drivers/net/ethernet/ti/am65-cpsw-qos.h | 102 ++++++++++++
5 files changed, 441 insertions(+)
Changelog:
v7:
- use else if
- drop FIXME comment
- fix lldp kselftest failure by limiting max_verify_time to spec limit of 128ms.
- now passes all ethtool_mm.sh kselftests (patch 8 required)
v6:
- get mutex around am65_cpsw_iet_commit_preemptible_tcs() in
am65_cpsw_iet_change_preemptible_tcs()
- use "preemption" instead of "pre-emption"
- call am65_cpsw_setup_mqprio() from within am65_cpsw_setup_taprio()
- Now works with kselftest except the last test which fails
v5:
- No change
v4:
- Rebase and include in the same series as mqprio support.
v3:
- Rebase on top of v6.6-rc1 and mqprio support [1]
- Support ethtool_ops :: get_mm_stats()
- drop unused variables cmn_ctrl and verify_cnt
- make am65_cpsw_iet_link_state_update() and
am65_cpsw_iet_change_preemptible_tcs() static
[1] https://lore.kernel.org/all/20230918075358.5878-1-rogerq@kernel.org/
v2:
- Use proper control bits for PMAC enable (AM65_CPSW_PN_CTL_IET_PORT_EN)
and TX enable (AM65_CPSW_PN_IET_MAC_PENABLE)
- Common IET Enable (AM65_CPSW_CTL_IET_EN) is set if any port has
AM65_CPSW_PN_CTL_IET_PORT_EN set.
- Fix workaround for erratum i2208. i.e. Limit rx_min_frag_size to 124
- Fix am65_cpsw_iet_get_verify_timeout_ms() to default to timeout for
1G link if link is inactive.
- resize the RX FIFO based on pmac_enabled, not tx_enabled.
@@ -740,6 +741,159 @@ static int am65_cpsw_set_ethtool_priv_flags(struct net_device *ndev, u32 flags)return0;}+staticvoidam65_cpsw_port_iet_rx_enable(structam65_cpsw_port*port,boolenable)+{+u32val;++val=readl(port->port_base+AM65_CPSW_PN_REG_CTL);+if(enable)+val|=AM65_CPSW_PN_CTL_IET_PORT_EN;+else+val&=~AM65_CPSW_PN_CTL_IET_PORT_EN;++writel(val,port->port_base+AM65_CPSW_PN_REG_CTL);+am65_cpsw_iet_common_enable(port->common);+}++staticvoidam65_cpsw_port_iet_tx_enable(structam65_cpsw_port*port,boolenable)+{+u32val;++val=readl(port->port_base+AM65_CPSW_PN_REG_IET_CTRL);+if(enable)+val|=AM65_CPSW_PN_IET_MAC_PENABLE;+else+val&=~AM65_CPSW_PN_IET_MAC_PENABLE;++writel(val,port->port_base+AM65_CPSW_PN_REG_IET_CTRL);+}++staticintam65_cpsw_get_mm(structnet_device*ndev,structethtool_mm_state*state)+{+structam65_cpsw_port*port=am65_ndev_to_port(ndev);+structam65_cpsw_ndev_priv*priv=netdev_priv(ndev);+u32port_ctrl,iet_ctrl,iet_status;+u32add_frag_size;++mutex_lock(&priv->mm_lock);++iet_ctrl=readl(port->port_base+AM65_CPSW_PN_REG_IET_CTRL);+port_ctrl=readl(port->port_base+AM65_CPSW_PN_REG_CTL);++state->tx_enabled=!!(iet_ctrl&AM65_CPSW_PN_IET_MAC_PENABLE);+state->pmac_enabled=!!(port_ctrl&AM65_CPSW_PN_CTL_IET_PORT_EN);++iet_status=readl(port->port_base+AM65_CPSW_PN_REG_IET_STATUS);++if(iet_ctrl&AM65_CPSW_PN_IET_MAC_DISABLEVERIFY)+state->verify_status=ETHTOOL_MM_VERIFY_STATUS_DISABLED;+elseif(iet_status&AM65_CPSW_PN_MAC_VERIFIED)+state->verify_status=ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED;+elseif(iet_status&AM65_CPSW_PN_MAC_VERIFY_FAIL)+state->verify_status=ETHTOOL_MM_VERIFY_STATUS_FAILED;+else+state->verify_status=ETHTOOL_MM_VERIFY_STATUS_UNKNOWN;++add_frag_size=AM65_CPSW_PN_IET_MAC_GET_ADDFRAGSIZE(iet_ctrl);+state->tx_min_frag_size=ethtool_mm_frag_size_add_to_min(add_frag_size);++/* Errata i2208: RX min fragment size cannot be less than 124 */+state->rx_min_frag_size=124;++/* FPE active if common tx_enabled and verification success or disabled (forced) */+state->tx_active=state->tx_enabled&&+(state->verify_status==ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED||+state->verify_status==ETHTOOL_MM_VERIFY_STATUS_DISABLED);+state->verify_enabled=!(iet_ctrl&AM65_CPSW_PN_IET_MAC_DISABLEVERIFY);++state->verify_time=port->qos.iet.verify_time_ms;++/* 802.3-2018 clause 30.14.1.6, says that the aMACMergeVerifyTime+*variablehasarangebetween1and128msinclusive.Limittothat.+*/+state->max_verify_time=128;++mutex_unlock(&priv->mm_lock);++return0;+}++staticintam65_cpsw_set_mm(structnet_device*ndev,structethtool_mm_cfg*cfg,+structnetlink_ext_ack*extack)+{+structam65_cpsw_port*port=am65_ndev_to_port(ndev);+structam65_cpsw_ndev_priv*priv=netdev_priv(ndev);+structam65_cpsw_iet*iet=&port->qos.iet;+u32val,add_frag_size;+interr;++err=ethtool_mm_frag_size_min_to_add(cfg->tx_min_frag_size,&add_frag_size,extack);+if(err)+returnerr;++mutex_lock(&priv->mm_lock);++if(cfg->pmac_enabled){+/* change TX & RX FIFO MAX_BLKS as per TRM recommendation */+if(!iet->original_max_blks)+iet->original_max_blks=readl(port->port_base+AM65_CPSW_PN_REG_MAX_BLKS);++writel(AM65_CPSW_PN_TX_RX_MAX_BLKS_IET,+port->port_base+AM65_CPSW_PN_REG_MAX_BLKS);+}elseif(iet->original_max_blks){+/* restore RX & TX FIFO MAX_BLKS */+writel(iet->original_max_blks,+port->port_base+AM65_CPSW_PN_REG_MAX_BLKS);+}++am65_cpsw_port_iet_rx_enable(port,cfg->pmac_enabled);+am65_cpsw_port_iet_tx_enable(port,cfg->tx_enabled);++val=readl(port->port_base+AM65_CPSW_PN_REG_IET_CTRL);+if(cfg->verify_enabled){+val&=~AM65_CPSW_PN_IET_MAC_DISABLEVERIFY;+/* Reset Verify state machine. Verification won't start here.+*Verificationwillbedoneoncelink-up.+*/+val|=AM65_CPSW_PN_IET_MAC_LINKFAIL;+}else{+val|=AM65_CPSW_PN_IET_MAC_DISABLEVERIFY;+/* Clear LINKFAIL to allow verify/response packets */+val&=~AM65_CPSW_PN_IET_MAC_LINKFAIL;+}++val&=~AM65_CPSW_PN_IET_MAC_MAC_ADDFRAGSIZE_MASK;+val|=AM65_CPSW_PN_IET_MAC_SET_ADDFRAGSIZE(add_frag_size);+writel(val,port->port_base+AM65_CPSW_PN_REG_IET_CTRL);++/* verify_timeout_count can only be set at valid link */+if(cfg->verify_time>0)+port->qos.iet.verify_time_ms=cfg->verify_time;+else+port->qos.iet.verify_time_ms=10;++/* enable/disable preemption based on link status */+am65_cpsw_iet_commit_preemptible_tcs(port);++mutex_unlock(&priv->mm_lock);++return0;+}++staticvoidam65_cpsw_get_mm_stats(structnet_device*ndev,+structethtool_mm_stats*s)+{+structam65_cpsw_port*port=am65_ndev_to_port(ndev);+void__iomem*base=port->stat_base;++s->MACMergeFrameAssOkCount=readl(base+AM65_CPSW_STATN_IET_RX_ASSEMBLY_OK);+s->MACMergeFrameAssErrorCount=readl(base+AM65_CPSW_STATN_IET_RX_ASSEMBLY_ERROR);+s->MACMergeFrameSmdErrorCount=readl(base+AM65_CPSW_STATN_IET_RX_SMD_ERROR);+s->MACMergeFragCountRx=readl(base+AM65_CPSW_STATN_IET_RX_FRAG);+s->MACMergeFragCountTx=readl(base+AM65_CPSW_STATN_IET_TX_FRAG);+s->MACMergeHoldCount=readl(base+AM65_CPSW_STATN_IET_TX_HOLD);+}+conststructethtool_opsam65_cpsw_ethtool_ops_slave={.begin=am65_cpsw_ethtool_op_begin,.complete=am65_cpsw_ethtool_op_complete,
@@ -170,6 +171,10 @@ struct am65_cpsw_ndev_priv {structam65_cpsw_port*port;structam65_cpsw_ndev_stats__percpu*stats;booloffload_fwd_mark;+/* Serialize access to MAC Merge state between ethtool requests+*andlinkstateupdates+*/+structmutexmm_lock;};#define am65_ndev_to_priv(ndev) \
@@ -23,6 +25,8 @@ enum timer_act {TACT_SKIP_PROG,/* just buffer can be updated */};+staticvoidam65_cpsw_iet_change_preemptible_tcs(structam65_cpsw_port*port,u8preemptible_tcs);+staticu32am65_cpsw_qos_tx_rate_calc(u32rate_mbps,unsignedlongbus_freq){
@@ -190,6 +194,8 @@ static void am65_cpsw_reset_tc_mqprio(struct net_device *ndev)/* Reset all Queue priorities to 0 */writel(0,port->port_base+AM65_CPSW_PN_REG_TX_PRI_MAP);++am65_cpsw_iet_change_preemptible_tcs(port,0);}staticintam65_cpsw_setup_mqprio(structnet_device*ndev,void*type_data)
@@ -259,6 +266,171 @@ static int am65_cpsw_setup_mqprio(struct net_device *ndev, void *type_data)returnret;}+staticintam65_cpsw_iet_set_verify_timeout_count(structam65_cpsw_port*port)+{+intverify_time_ms=port->qos.iet.verify_time_ms;+u32val;++/* The number of wireside clocks contained in the verify+*timeoutcounter.Thedefaultis0x1312d0+*(10msat125Mhzin1Gmode).+*/+val=125*HZ_PER_MHZ;/* assuming 125MHz wireside clock */++val/=MILLIHZ_PER_HZ;/* count per ms timeout */+val*=verify_time_ms;/* count for timeout ms */++if(val>AM65_CPSW_PN_MAC_VERIFY_CNT_MASK)+return-EINVAL;++writel(val,port->port_base+AM65_CPSW_PN_REG_IET_VERIFY);++return0;+}++staticintam65_cpsw_iet_verify_wait(structam65_cpsw_port*port)+{+u32ctrl,status;+inttry;++try=20;+do{+/* Reset the verify state machine by writing 1+*toLINKFAIL+*/+ctrl=readl(port->port_base+AM65_CPSW_PN_REG_IET_CTRL);+ctrl|=AM65_CPSW_PN_IET_MAC_LINKFAIL;+writel(ctrl,port->port_base+AM65_CPSW_PN_REG_IET_CTRL);++/* Clear MAC_LINKFAIL bit to start Verify. */+ctrl=readl(port->port_base+AM65_CPSW_PN_REG_IET_CTRL);+ctrl&=~AM65_CPSW_PN_IET_MAC_LINKFAIL;+writel(ctrl,port->port_base+AM65_CPSW_PN_REG_IET_CTRL);++msleep(port->qos.iet.verify_time_ms);++status=readl(port->port_base+AM65_CPSW_PN_REG_IET_STATUS);+if(status&AM65_CPSW_PN_MAC_VERIFIED)+return0;++if(status&AM65_CPSW_PN_MAC_VERIFY_FAIL){+netdev_dbg(port->ndev,+"MAC Merge verify failed, trying again\n");+continue;+}++if(status&AM65_CPSW_PN_MAC_RESPOND_ERR){+netdev_dbg(port->ndev,"MAC Merge respond error\n");+return-ENODEV;+}++if(status&AM65_CPSW_PN_MAC_VERIFY_ERR){+netdev_dbg(port->ndev,"MAC Merge verify error\n");+return-ENODEV;+}+}while(try-->0);++netdev_dbg(port->ndev,"MAC Merge verify timeout\n");+return-ETIMEDOUT;+}++staticvoidam65_cpsw_iet_set_preempt_mask(structam65_cpsw_port*port,u8preemptible_tcs)+{+u32val;++val=readl(port->port_base+AM65_CPSW_PN_REG_IET_CTRL);+val&=~AM65_CPSW_PN_IET_MAC_PREMPT_MASK;+val|=AM65_CPSW_PN_IET_MAC_SET_PREEMPT(preemptible_tcs);+writel(val,port->port_base+AM65_CPSW_PN_REG_IET_CTRL);+}++/* enable common IET_ENABLE only if at least 1 port has rx IET enabled.+*UAPIdoesn'tallowtxenablewithoutrxenable.+*/+voidam65_cpsw_iet_common_enable(structam65_cpsw_common*common)+{+structam65_cpsw_port*port;+boolrx_enable=false;+u32val;+inti;++for(i=0;i<common->port_num;i++){+port=&common->ports[i];+val=readl(port->port_base+AM65_CPSW_PN_REG_CTL);+rx_enable=!!(val&AM65_CPSW_PN_CTL_IET_PORT_EN);+if(rx_enable)+break;+}++val=readl(common->cpsw_base+AM65_CPSW_REG_CTL);++if(rx_enable)+val|=AM65_CPSW_CTL_IET_EN;+else+val&=~AM65_CPSW_CTL_IET_EN;++writel(val,common->cpsw_base+AM65_CPSW_REG_CTL);+common->iet_enabled=rx_enable;+}++/* CPSW does not have an IRQ to notify changes to the MAC Merge TX status+*(active/inactive),butthepreemptibletrafficclassesshouldonlybe+*committedtohardwareonceTXisactive.Resorttopolling.+*/+voidam65_cpsw_iet_commit_preemptible_tcs(structam65_cpsw_port*port)+{+u8preemptible_tcs;+interr;+u32val;++if(port->qos.link_speed==SPEED_UNKNOWN)+return;++val=readl(port->port_base+AM65_CPSW_PN_REG_CTL);+if(!(val&AM65_CPSW_PN_CTL_IET_PORT_EN))+return;++/* update common IET enable */+am65_cpsw_iet_common_enable(port->common);++/* update verify count */+err=am65_cpsw_iet_set_verify_timeout_count(port);+if(err){+netdev_err(port->ndev,"couldn't set verify count: %d\n",err);+return;+}++val=readl(port->port_base+AM65_CPSW_PN_REG_IET_CTRL);+if(!(val&AM65_CPSW_PN_IET_MAC_DISABLEVERIFY)){+err=am65_cpsw_iet_verify_wait(port);+if(err)+return;+}++preemptible_tcs=port->qos.iet.preemptible_tcs;+am65_cpsw_iet_set_preempt_mask(port,preemptible_tcs);+}++staticvoidam65_cpsw_iet_change_preemptible_tcs(structam65_cpsw_port*port,u8preemptible_tcs)+{+structam65_cpsw_ndev_priv*priv=am65_ndev_to_priv(port->ndev);++port->qos.iet.preemptible_tcs=preemptible_tcs;+mutex_lock(&priv->mm_lock);+am65_cpsw_iet_commit_preemptible_tcs(port);+mutex_unlock(&priv->mm_lock);+}++staticvoidam65_cpsw_iet_link_state_update(structnet_device*ndev)+{+structam65_cpsw_ndev_priv*priv=am65_ndev_to_priv(ndev);+structam65_cpsw_port*port=am65_ndev_to_port(ndev);++mutex_lock(&priv->mm_lock);+am65_cpsw_iet_commit_preemptible_tcs(port);+mutex_unlock(&priv->mm_lock);+}+staticintam65_cpsw_port_est_enabled(structam65_cpsw_port*port){returnport->qos.est_oper||port->qos.est_admin;
@@ -735,6 +907,7 @@ static int am65_cpsw_taprio_replace(struct net_device *ndev,devm_kfree(&ndev->dev,port->qos.est_admin);port->qos.est_admin=est_new;+am65_cpsw_iet_change_preemptible_tcs(port,taprio->mqprio.preemptible_tcs);return0;
@@ -1114,6 +1287,7 @@ void am65_cpsw_qos_link_up(struct net_device *ndev, int link_speed)port->qos.link_speed=link_speed;am65_cpsw_tx_pn_shaper_apply(port);+am65_cpsw_iet_link_state_update(ndev);am65_cpsw_est_link_up(ndev,link_speed);port->qos.link_down_time=0;
@@ -894,6 +894,80 @@ static void am65_cpsw_get_mm_stats(struct net_device *ndev,s->MACMergeHoldCount=readl(base+AM65_CPSW_STATN_IET_TX_HOLD);}+staticintam65_cpsw_get_coalesce(structnet_device*ndev,structethtool_coalesce*coal,+structkernel_ethtool_coalesce*kernel_coal,+structnetlink_ext_ack*extack)+{+structam65_cpsw_common*common=am65_ndev_to_common(ndev);+structam65_cpsw_tx_chn*tx_chn;++tx_chn=&common->tx_chns[0];++coal->rx_coalesce_usecs=common->rx_pace_timeout/1000;+coal->tx_coalesce_usecs=tx_chn->tx_pace_timeout/1000;++return0;+}++staticintam65_cpsw_get_per_queue_coalesce(structnet_device*ndev,u32queue,+structethtool_coalesce*coal)+{+structam65_cpsw_common*common=am65_ndev_to_common(ndev);+structam65_cpsw_tx_chn*tx_chn;++if(queue>=AM65_CPSW_MAX_TX_QUEUES)+return-EINVAL;++tx_chn=&common->tx_chns[queue];++coal->tx_coalesce_usecs=tx_chn->tx_pace_timeout/1000;++return0;+}++staticintam65_cpsw_set_coalesce(structnet_device*ndev,structethtool_coalesce*coal,+structkernel_ethtool_coalesce*kernel_coal,+structnetlink_ext_ack*extack)+{+structam65_cpsw_common*common=am65_ndev_to_common(ndev);+structam65_cpsw_tx_chn*tx_chn;++tx_chn=&common->tx_chns[0];++if(coal->rx_coalesce_usecs&&coal->rx_coalesce_usecs<20)+return-EINVAL;++if(coal->tx_coalesce_usecs&&coal->tx_coalesce_usecs<20)+return-EINVAL;++common->rx_pace_timeout=coal->rx_coalesce_usecs*1000;+tx_chn->tx_pace_timeout=coal->tx_coalesce_usecs*1000;++return0;+}++staticintam65_cpsw_set_per_queue_coalesce(structnet_device*ndev,u32queue,+structethtool_coalesce*coal)+{+structam65_cpsw_common*common=am65_ndev_to_common(ndev);+structam65_cpsw_tx_chn*tx_chn;++if(queue>=AM65_CPSW_MAX_TX_QUEUES)+return-EINVAL;++tx_chn=&common->tx_chns[queue];++if(coal->tx_coalesce_usecs&&coal->tx_coalesce_usecs<20){+dev_info(common->dev,"defaulting to min value of 20us for tx-usecs for tx-%u\n",+queue);+coal->tx_coalesce_usecs=20;+}++tx_chn->tx_pace_timeout=coal->tx_coalesce_usecs*1000;++return0;+}+conststructethtool_opsam65_cpsw_ethtool_ops_slave={.begin=am65_cpsw_ethtool_op_begin,.complete=am65_cpsw_ethtool_op_complete,
From: Roger Quadros <rogerq@kernel.org> Date: 2023-12-01 13:58:37
From: Vladimir Oltean <vladimir.oltean@nxp.com>
Some devices have errata due to which they cannot report ETH_ZLEN (60)
in the rx-min-frag-size. This was foreseen of course, and lldpad has
logic that when we request it to advertise addFragSize 0, it will round
it up to the lowest value that is _actually_ supported by the hardware.
The problem is that the selftest expects lldpad to report back to us the
same value as we requested.
Make the selftest smarter by figuring out on its own what is a
reasonable value to expect.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Roger Quadros <rogerq@kernel.org>
---
.../selftests/net/forwarding/ethtool_mm.sh | 37 ++++++++++++++++++-
1 file changed, 35 insertions(+), 2 deletions(-)
Changelog:
v7: initial commit
@@ -155,15 +155,48 @@ manual_failed_verification_h2_to_h1()manual_failed_verification$h2$h1}+smallest_supported_add_frag_size()+{+localiface=$1+localrx_min_frag_size=++rx_min_frag_size=$(ethtool--json--show-mm$iface|\+jq'.[]."rx-min-frag-size"')++if[$rx_min_frag_size-le60];then+echo0+elif[$rx_min_frag_size-le124];then+echo1+elif[$rx_min_frag_size-le188];then+echo2+elif[$rx_min_frag_size-le252];then+echo3+else+echo"$iface: RX min frag size $rx_min_frag_size cannot be advertised over LLDP"+exit1+fi+}++expected_add_frag_size()+{+localiface=$1+localrequested=$2+localmin=$(smallest_supported_add_frag_size$iface)++[$requested-le$min]&&echo$min||echo$requested+}+ lldp_change_add_frag_size(){localadd_frag_size=$1+localpattern=lldptool-T-i$h1-VaddEthCapsaddFragSize=$add_frag_size>/dev/null# Wait for TLVs to be receivedsleep2-lldptool-i$h2-t-n-VaddEthCaps|\-grep-q"Additional fragment size: $add_frag_size"+pattern=$(printf"Additional fragment size: %d"\+$(expected_add_frag_size$h1$add_frag_size))+lldptool-i$h2-t-n-VaddEthCaps|grep-q"$pattern"} lldp()
From: Varis, Pekka <hidden> Date: 2023-12-01 16:01:45
-----Original Message-----
From: Roger Quadros <rogerq@kernel.org>
Add driver support for viewing / changing the MAC Merge sublayer
parameters and seeing the verification state machine's current state via
ethtool.
As hardware does not support interrupt notification for verification events
we resort to polling on link up. On link up we try a couple of times for
verification success and if unsuccessful then give up.
The Frame Preemption feature is described in the Technical Reference
Manual [1] in section:
12.3.1.4.6.7 Intersperced Express Traffic (IET – P802.3br/D2.0)
Due to Silicon Errata i2208 [2] we set limit min IET fragment size to 124.
Should be 128 not 124
[1] AM62x TRM - https://www.ti.com/lit/ug/spruiv7a/spruiv7a.pdf
[2] AM62x Silicon Errata - https://www.ti.com/lit/er/sprz487c/sprz487c.pdf
Signed-off-by: Roger Quadros <rogerq@kernel.org>
---
drivers/net/ethernet/ti/am65-cpsw-ethtool.c | 157 ++++++++++++++++++
drivers/net/ethernet/ti/am65-cpsw-nuss.c | 2 +
drivers/net/ethernet/ti/am65-cpsw-nuss.h | 5 +
drivers/net/ethernet/ti/am65-cpsw-qos.c | 175 ++++++++++++++++++++
drivers/net/ethernet/ti/am65-cpsw-qos.h | 102 ++++++++++++
5 files changed, 441 insertions(+)
Changelog:
v7:
- use else if
- drop FIXME comment
- fix lldp kselftest failure by limiting max_verify_time to spec limit of 128ms.
- now passes all ethtool_mm.sh kselftests (patch 8 required)
v6:
- get mutex around am65_cpsw_iet_commit_preemptible_tcs() in
am65_cpsw_iet_change_preemptible_tcs()
- use "preemption" instead of "pre-emption"
- call am65_cpsw_setup_mqprio() from within am65_cpsw_setup_taprio()
- Now works with kselftest except the last test which fails
v5:
- No change
v4:
- Rebase and include in the same series as mqprio support.
v3:
- Rebase on top of v6.6-rc1 and mqprio support [1]
- Support ethtool_ops :: get_mm_stats()
- drop unused variables cmn_ctrl and verify_cnt
- make am65_cpsw_iet_link_state_update() and
am65_cpsw_iet_change_preemptible_tcs() static
[1] https://lore.kernel.org/all/20230918075358.5878-1-rogerq@kernel.org/
v2:
- Use proper control bits for PMAC enable
(AM65_CPSW_PN_CTL_IET_PORT_EN)
and TX enable (AM65_CPSW_PN_IET_MAC_PENABLE)
- Common IET Enable (AM65_CPSW_CTL_IET_EN) is set if any port has
AM65_CPSW_PN_CTL_IET_PORT_EN set.
- Fix workaround for erratum i2208. i.e. Limit rx_min_frag_size to 124
Should be 128 not 124
quoted hunk
- Fix am65_cpsw_iet_get_verify_timeout_ms() to default to timeout for
1G link if link is inactive.
- resize the RX FIFO based on pmac_enabled, not tx_enabled.
From: Roger Quadros <rogerq@kernel.org> Date: 2023-12-04 09:30:59
Hi Pekka,
On 01/12/2023 18:01, Varis, Pekka wrote:
quoted
-----Original Message-----
From: Roger Quadros <rogerq@kernel.org>
Add driver support for viewing / changing the MAC Merge sublayer
parameters and seeing the verification state machine's current state via
ethtool.
As hardware does not support interrupt notification for verification events
we resort to polling on link up. On link up we try a couple of times for
verification success and if unsuccessful then give up.
The Frame Preemption feature is described in the Technical Reference
Manual [1] in section:
12.3.1.4.6.7 Intersperced Express Traffic (IET – P802.3br/D2.0)
Due to Silicon Errata i2208 [2] we set limit min IET fragment size to 124.
Should be 128 not 124
User space setting is without FCS.
quoted
[1] AM62x TRM - https://www.ti.com/lit/ug/spruiv7a/spruiv7a.pdf
[2] AM62x Silicon Errata - https://www.ti.com/lit/er/sprz487c/sprz487c.pdf
Signed-off-by: Roger Quadros <rogerq@kernel.org>
---
drivers/net/ethernet/ti/am65-cpsw-ethtool.c | 157 ++++++++++++++++++
drivers/net/ethernet/ti/am65-cpsw-nuss.c | 2 +
drivers/net/ethernet/ti/am65-cpsw-nuss.h | 5 +
drivers/net/ethernet/ti/am65-cpsw-qos.c | 175 ++++++++++++++++++++
drivers/net/ethernet/ti/am65-cpsw-qos.h | 102 ++++++++++++
5 files changed, 441 insertions(+)
Changelog:
v7:
- use else if
- drop FIXME comment
- fix lldp kselftest failure by limiting max_verify_time to spec limit of 128ms.
- now passes all ethtool_mm.sh kselftests (patch 8 required)
v6:
- get mutex around am65_cpsw_iet_commit_preemptible_tcs() in
am65_cpsw_iet_change_preemptible_tcs()
- use "preemption" instead of "pre-emption"
- call am65_cpsw_setup_mqprio() from within am65_cpsw_setup_taprio()
- Now works with kselftest except the last test which fails
v5:
- No change
v4:
- Rebase and include in the same series as mqprio support.
v3:
- Rebase on top of v6.6-rc1 and mqprio support [1]
- Support ethtool_ops :: get_mm_stats()
- drop unused variables cmn_ctrl and verify_cnt
- make am65_cpsw_iet_link_state_update() and
am65_cpsw_iet_change_preemptible_tcs() static
[1] https://lore.kernel.org/all/20230918075358.5878-1-rogerq@kernel.org/
v2:
- Use proper control bits for PMAC enable
(AM65_CPSW_PN_CTL_IET_PORT_EN)
and TX enable (AM65_CPSW_PN_IET_MAC_PENABLE)
- Common IET Enable (AM65_CPSW_CTL_IET_EN) is set if any port has
AM65_CPSW_PN_CTL_IET_PORT_EN set.
- Fix workaround for erratum i2208. i.e. Limit rx_min_frag_size to 124
Should be 128 not 124
quoted
- Fix am65_cpsw_iet_get_verify_timeout_ms() to default to timeout for
1G link if link is inactive.
- resize the RX FIFO based on pmac_enabled, not tx_enabled.
/* Errata i2208: RX min fragment size cannot be less than 128 */
state->rx_min_frag_size = 128;
ethtool man page says
" tx-min-frag-size
Shows the minimum size (in octets) of transmitted non-
final fragments which can be received by the link
partner. Corresponds to the standard addFragSize
variable using the formula:
tx-min-frag-size = 64 * (1 + addFragSize) - 4"
Which means user needs to put a -4 offset i.e. drop FCS size.
Drivers show rx-min-frag-size also without the FCS.
e.g.
https://elixir.bootlin.com/linux/latest/source/drivers/net/ethernet/mscc/ocelot_mm.c#L260
--
cheers,
-roger
From: Vladimir Oltean <vladimir.oltean@nxp.com> Date: 2023-12-04 11:02:55
On Mon, Dec 04, 2023 at 11:30:53AM +0200, Roger Quadros wrote:
quoted
quoted
Due to Silicon Errata i2208 [2] we set limit min IET fragment size to 124.
Should be 128 not 124
User space setting is without FCS.
Technically it's called mCRC for preemptible frames, but yes.
quoted
quoted
+ /* Errata i2208: RX min fragment size cannot be less than 124 */
+ state->rx_min_frag_size = 124;
/* Errata i2208: RX min fragment size cannot be less than 128 */
state->rx_min_frag_size = 128;
ethtool man page says
" tx-min-frag-size
Shows the minimum size (in octets) of transmitted non-
final fragments which can be received by the link
partner. Corresponds to the standard addFragSize
variable using the formula:
tx-min-frag-size = 64 * (1 + addFragSize) - 4"
Which means user needs to put a -4 offset i.e. drop FCS size.
Drivers show rx-min-frag-size also without the FCS.
e.g.
https://elixir.bootlin.com/linux/latest/source/drivers/net/ethernet/mscc/ocelot_mm.c#L260
From: Vladimir Oltean <vladimir.oltean@nxp.com> Date: 2023-12-04 11:10:17
On Fri, Dec 01, 2023 at 03:58:00PM +0200, Roger Quadros wrote:
Add driver support for viewing / changing the MAC Merge sublayer
parameters and seeing the verification state machine's current state
via ethtool.
As hardware does not support interrupt notification for verification
events we resort to polling on link up. On link up we try a couple of
times for verification success and if unsuccessful then give up.
The Frame Preemption feature is described in the Technical Reference
Manual [1] in section:
12.3.1.4.6.7 Intersperced Express Traffic (IET – P802.3br/D2.0)
Due to Silicon Errata i2208 [2] we set limit min IET fragment size to 124.
[1] AM62x TRM - https://www.ti.com/lit/ug/spruiv7a/spruiv7a.pdf
[2] AM62x Silicon Errata - https://www.ti.com/lit/er/sprz487c/sprz487c.pdf
Signed-off-by: Roger Quadros <rogerq@kernel.org>
---
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
pw-bot: under-review
From: Vladimir Oltean <vladimir.oltean@nxp.com> Date: 2023-12-04 11:14:03
On Fri, Dec 01, 2023 at 03:58:02PM +0200, Roger Quadros wrote:
From: Vladimir Oltean <vladimir.oltean@nxp.com>
Some devices have errata due to which they cannot report ETH_ZLEN (60)
in the rx-min-frag-size. This was foreseen of course, and lldpad has
logic that when we request it to advertise addFragSize 0, it will round
it up to the lowest value that is _actually_ supported by the hardware.
The problem is that the selftest expects lldpad to report back to us the
same value as we requested.
Make the selftest smarter by figuring out on its own what is a
reasonable value to expect.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Roger Quadros <rogerq@kernel.org>
---
This needs your sign off as well after mine, otherwise in the git log it
will imply that I sent the patch myself. I think you can reply with the
tag to this email and either the patchwork bot or one of the maintainers
will pick it up automatically, it's not a reason in itself to resend.
From: Vladimir Oltean <vladimir.oltean@nxp.com> Date: 2023-12-04 12:35:38
On Fri, Dec 01, 2023 at 03:58:00PM +0200, Roger Quadros wrote:
Add driver support for viewing / changing the MAC Merge sublayer
parameters and seeing the verification state machine's current state
via ethtool.
As hardware does not support interrupt notification for verification
events we resort to polling on link up. On link up we try a couple of
times for verification success and if unsuccessful then give up.
The Frame Preemption feature is described in the Technical Reference
Manual [1] in section:
12.3.1.4.6.7 Intersperced Express Traffic (IET – P802.3br/D2.0)
Due to Silicon Errata i2208 [2] we set limit min IET fragment size to 124.
[1] AM62x TRM - https://www.ti.com/lit/ug/spruiv7a/spruiv7a.pdf
[2] AM62x Silicon Errata - https://www.ti.com/lit/er/sprz487c/sprz487c.pdf
Signed-off-by: Roger Quadros <rogerq@kernel.org>
---
referenced by am65-cpsw-ethtool.c:755 (drivers/net/ethernet/ti/am65-cpsw-ethtool.c:755)
drivers/net/ethernet/ti/am65-cpsw-ethtool.o:(am65_cpsw_set_mm) in archive vmlinux.a
referenced by am65-cpsw-ethtool.c:876 (drivers/net/ethernet/ti/am65-cpsw-ethtool.c:876)
drivers/net/ethernet/ti/am65-cpsw-ethtool.o:(am65_cpsw_set_mm) in archive vmlinux.a
cat $KBUILD_OUTPUT/.config | grep AM65
CONFIG_TI_K3_AM65_CPSW_NUSS=y
# CONFIG_TI_K3_AM65_CPSW_SWITCHDEV is not set
# CONFIG_TI_K3_AM65_CPTS is not set
CONFIG_MMC_SDHCI_AM654=y
CONFIG_PHY_AM654_SERDES=m
am65-cpsw-qos.c is built only if CONFIG_TI_AM65_CPSW_TAS is enabled, yet am65-cpsw-ethtool.c,
built by CONFIG_TI_K3_AM65_CPSW_NUSS, depends on it.
From: Vladimir Oltean <vladimir.oltean@nxp.com> Date: 2023-12-04 12:37:02
On Fri, Dec 01, 2023 at 03:58:02PM +0200, Roger Quadros wrote:
From: Vladimir Oltean <vladimir.oltean@nxp.com>
Some devices have errata due to which they cannot report ETH_ZLEN (60)
in the rx-min-frag-size. This was foreseen of course, and lldpad has
logic that when we request it to advertise addFragSize 0, it will round
it up to the lowest value that is _actually_ supported by the hardware.
The problem is that the selftest expects lldpad to report back to us the
same value as we requested.
Make the selftest smarter by figuring out on its own what is a
reasonable value to expect.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Roger Quadros <rogerq@kernel.org>
---
When you do resend, please make sure that this change is present before
your driver support, such that bisections show that the selftest passes
since the very introduction of this feature.
From: Vladimir Oltean <vladimir.oltean@nxp.com> Date: 2023-12-04 13:38:30
On Fri, Dec 01, 2023 at 03:57:56PM +0200, Roger Quadros wrote:
Handle offloading commands using switch-case in
am65_cpsw_setup_taprio().
Move checks to am65_cpsw_taprio_replace().
Use NL_SET_ERR_MSG_MOD for error messages.
Change error message from "Failed to set cycle time extension"
to "cycle time extension not supported"
Signed-off-by: Roger Quadros <rogerq@kernel.org>
---
After this change (I guess), it's pointless to initialize
int ret = 0, tact = TACT_PROG;
when both will be overwritten later in am65_cpsw_taprio_replace(), and
nothing depends upon their initial values.
Can be rewritten as ((x) * BITS_PER_BYTE / MEGA)
and further as ((x) / BYTES_PER_MBIT).
Also, I wonder if it wouldn't be better to do a DIV_ROUND_UP(x, BYTES_PER_MBIT)
instead. When user space requests a certain bandwidth, it expects to get it.
If the hardware is not fine grained enough, it should prefer giving it slightly
more rather than slightly less.
From: Vladimir Oltean <vladimir.oltean@nxp.com> Date: 2023-12-07 15:24:15
On Fri, Dec 01, 2023 at 03:58:00PM +0200, Roger Quadros wrote:
- now passes all ethtool_mm.sh kselftests (patch 8 required)
There's another problem with your patch set, leading to the
traffic_test() selftest passing with the "emac" and "pmac" argument when
it shouldn't.
Drivers which implement frame preemption are supposed to be prepared to
distinguish, in their ethtool get_eth_mac_stats() method, between
ETHTOOL_MAC_STATS_SRC_EMAC, ETHTOOL_MAC_STATS_SRC_PMAC and
ETHTOOL_MAC_STATS_SRC_AGGREGATE. You don't, so you report the same thing
everywhere, which is incorrect, and it also fools the selftest.
I would like you to figure out which source are your stats coming from,
reject everything else, and edit the selftest to do something sensible
for your hardware. If it's as I suspect and the reported counters are
eMAC+pMAC aggregates, then I guess the most sensible thing to do would
be to probe the device with an ethtool -S --src pmac at the beginning of
the test, see what it reports, and if we don't get pMAC counters from
it, fall back to aggregate ones during calls to traffic_test().
From: Roger Quadros <rogerq@kernel.org> Date: 2023-12-08 10:13:29
On 04/12/2023 14:35, Vladimir Oltean wrote:
On Fri, Dec 01, 2023 at 03:58:00PM +0200, Roger Quadros wrote:
quoted
Add driver support for viewing / changing the MAC Merge sublayer
parameters and seeing the verification state machine's current state
via ethtool.
As hardware does not support interrupt notification for verification
events we resort to polling on link up. On link up we try a couple of
times for verification success and if unsuccessful then give up.
The Frame Preemption feature is described in the Technical Reference
Manual [1] in section:
12.3.1.4.6.7 Intersperced Express Traffic (IET – P802.3br/D2.0)
Due to Silicon Errata i2208 [2] we set limit min IET fragment size to 124.
[1] AM62x TRM - https://www.ti.com/lit/ug/spruiv7a/spruiv7a.pdf
[2] AM62x Silicon Errata - https://www.ti.com/lit/er/sprz487c/sprz487c.pdf
Signed-off-by: Roger Quadros <rogerq@kernel.org>
---
referenced by am65-cpsw-ethtool.c:755 (drivers/net/ethernet/ti/am65-cpsw-ethtool.c:755)
drivers/net/ethernet/ti/am65-cpsw-ethtool.o:(am65_cpsw_set_mm) in archive vmlinux.a
referenced by am65-cpsw-ethtool.c:876 (drivers/net/ethernet/ti/am65-cpsw-ethtool.c:876)
drivers/net/ethernet/ti/am65-cpsw-ethtool.o:(am65_cpsw_set_mm) in archive vmlinux.a
cat $KBUILD_OUTPUT/.config | grep AM65
CONFIG_TI_K3_AM65_CPSW_NUSS=y
# CONFIG_TI_K3_AM65_CPSW_SWITCHDEV is not set
# CONFIG_TI_K3_AM65_CPTS is not set
CONFIG_MMC_SDHCI_AM654=y
CONFIG_PHY_AM654_SERDES=m
am65-cpsw-qos.c is built only if CONFIG_TI_AM65_CPSW_TAS is enabled, yet am65-cpsw-ethtool.c,
built by CONFIG_TI_K3_AM65_CPSW_NUSS, depends on it.
Wondering how to fix this the right way. Should set/get_mm fail if CONFIG_TI_AM65_CPSW_TAS is not enabled?
--
cheers,
-roger
From: Roger Quadros <rogerq@kernel.org> Date: 2023-12-08 10:26:31
On 08/12/2023 12:13, Roger Quadros wrote:
On 04/12/2023 14:35, Vladimir Oltean wrote:
quoted
On Fri, Dec 01, 2023 at 03:58:00PM +0200, Roger Quadros wrote:
quoted
Add driver support for viewing / changing the MAC Merge sublayer
parameters and seeing the verification state machine's current state
via ethtool.
As hardware does not support interrupt notification for verification
events we resort to polling on link up. On link up we try a couple of
times for verification success and if unsuccessful then give up.
The Frame Preemption feature is described in the Technical Reference
Manual [1] in section:
12.3.1.4.6.7 Intersperced Express Traffic (IET – P802.3br/D2.0)
Due to Silicon Errata i2208 [2] we set limit min IET fragment size to 124.
[1] AM62x TRM - https://www.ti.com/lit/ug/spruiv7a/spruiv7a.pdf
[2] AM62x Silicon Errata - https://www.ti.com/lit/er/sprz487c/sprz487c.pdf
Signed-off-by: Roger Quadros <rogerq@kernel.org>
---
referenced by am65-cpsw-ethtool.c:755 (drivers/net/ethernet/ti/am65-cpsw-ethtool.c:755)
drivers/net/ethernet/ti/am65-cpsw-ethtool.o:(am65_cpsw_set_mm) in archive vmlinux.a
referenced by am65-cpsw-ethtool.c:876 (drivers/net/ethernet/ti/am65-cpsw-ethtool.c:876)
drivers/net/ethernet/ti/am65-cpsw-ethtool.o:(am65_cpsw_set_mm) in archive vmlinux.a
cat $KBUILD_OUTPUT/.config | grep AM65
CONFIG_TI_K3_AM65_CPSW_NUSS=y
# CONFIG_TI_K3_AM65_CPSW_SWITCHDEV is not set
# CONFIG_TI_K3_AM65_CPTS is not set
CONFIG_MMC_SDHCI_AM654=y
CONFIG_PHY_AM654_SERDES=m
am65-cpsw-qos.c is built only if CONFIG_TI_AM65_CPSW_TAS is enabled, yet am65-cpsw-ethtool.c,
built by CONFIG_TI_K3_AM65_CPSW_NUSS, depends on it.
Wondering how to fix this the right way. Should set/get_mm fail if CONFIG_TI_AM65_CPSW_TAS is not enabled?
From: Roger Quadros <rogerq@kernel.org> Date: 2023-12-08 12:33:06
On 08/12/2023 12:26, Roger Quadros wrote:
quoted hunk
On 08/12/2023 12:13, Roger Quadros wrote:
quoted
On 04/12/2023 14:35, Vladimir Oltean wrote:
quoted
On Fri, Dec 01, 2023 at 03:58:00PM +0200, Roger Quadros wrote:
quoted
Add driver support for viewing / changing the MAC Merge sublayer
parameters and seeing the verification state machine's current state
via ethtool.
As hardware does not support interrupt notification for verification
events we resort to polling on link up. On link up we try a couple of
times for verification success and if unsuccessful then give up.
The Frame Preemption feature is described in the Technical Reference
Manual [1] in section:
12.3.1.4.6.7 Intersperced Express Traffic (IET – P802.3br/D2.0)
Due to Silicon Errata i2208 [2] we set limit min IET fragment size to 124.
[1] AM62x TRM - https://www.ti.com/lit/ug/spruiv7a/spruiv7a.pdf
[2] AM62x Silicon Errata - https://www.ti.com/lit/er/sprz487c/sprz487c.pdf
Signed-off-by: Roger Quadros <rogerq@kernel.org>
---
referenced by am65-cpsw-ethtool.c:755 (drivers/net/ethernet/ti/am65-cpsw-ethtool.c:755)
drivers/net/ethernet/ti/am65-cpsw-ethtool.o:(am65_cpsw_set_mm) in archive vmlinux.a
referenced by am65-cpsw-ethtool.c:876 (drivers/net/ethernet/ti/am65-cpsw-ethtool.c:876)
drivers/net/ethernet/ti/am65-cpsw-ethtool.o:(am65_cpsw_set_mm) in archive vmlinux.a
cat $KBUILD_OUTPUT/.config | grep AM65
CONFIG_TI_K3_AM65_CPSW_NUSS=y
# CONFIG_TI_K3_AM65_CPSW_SWITCHDEV is not set
# CONFIG_TI_K3_AM65_CPTS is not set
CONFIG_MMC_SDHCI_AM654=y
CONFIG_PHY_AM654_SERDES=m
am65-cpsw-qos.c is built only if CONFIG_TI_AM65_CPSW_TAS is enabled, yet am65-cpsw-ethtool.c,
built by CONFIG_TI_K3_AM65_CPSW_NUSS, depends on it.
Wondering how to fix this the right way. Should set/get_mm fail if CONFIG_TI_AM65_CPSW_TAS is not enabled?
But,
bool __ethtool_dev_mm_supported(struct net_device *dev)
{
const struct ethtool_ops *ops = dev->ethtool_ops;
struct ethtool_mm_state state = {};
int ret = -EOPNOTSUPP;
if (ops && ops->get_mm)
ret = ops->get_mm(dev, &state);
return !ret;
}
So looks like it is better to not define get_mm/set_mm if CONFIG_TI_AM65_CPSW_TAS is disabled.
--
cheers,
-roger
From: Roger Quadros <rogerq@kernel.org> Date: 2023-12-08 13:43:51
On 07/12/2023 17:24, Vladimir Oltean wrote:
On Fri, Dec 01, 2023 at 03:58:00PM +0200, Roger Quadros wrote:
quoted
- now passes all ethtool_mm.sh kselftests (patch 8 required)
There's another problem with your patch set, leading to the
traffic_test() selftest passing with the "emac" and "pmac" argument when
it shouldn't.
Drivers which implement frame preemption are supposed to be prepared to
distinguish, in their ethtool get_eth_mac_stats() method, between
ETHTOOL_MAC_STATS_SRC_EMAC, ETHTOOL_MAC_STATS_SRC_PMAC and
ETHTOOL_MAC_STATS_SRC_AGGREGATE. You don't, so you report the same thing
everywhere, which is incorrect, and it also fools the selftest.
I would like you to figure out which source are your stats coming from,
reject everything else, and edit the selftest to do something sensible
for your hardware. If it's as I suspect and the reported counters are
eMAC+pMAC aggregates, then I guess the most sensible thing to do would
be to probe the device with an ethtool -S --src pmac at the beginning of
the test, see what it reports, and if we don't get pMAC counters from
it, fall back to aggregate ones during calls to traffic_test().
Thanks for the catch.
How do the below 2 patches look to resolve this?
From af2a8503dc04c54d6eaf50954628009aba54e2c8 Mon Sep 17 00:00:00 2001
From: Roger Quadros <rogerq@kernel.org>
Date: Fri, 8 Dec 2023 15:11:06 +0200
Subject: [PATCH] net: ethernet: ti: am65-cpsw: Fix get_eth_mac_stats
We do not support individual stats for PMAC and EMAC so
report only aggregate stats.
Fixes: 67372d7a85fcd ("net: ethernet: am65-cpsw: Add standard Ethernet MAC stats to ethtool")
Signed-off-by: Roger Quadros <rogerq@kernel.org>
---
drivers/net/ethernet/ti/am65-cpsw-ethtool.c | 37 ++++++++++++---------
1 file changed, 22 insertions(+), 15 deletions(-)
base-commit: a78e0a2c4353d6c100e45c5ef738113bf2d0fda5
--
2.34.1
From 0b20d8b8ef110d886396ee2486f3a9e20170cc85 Mon Sep 17 00:00:00 2001
From: Roger Quadros <rogerq@kernel.org>
Date: Fri, 8 Dec 2023 15:38:57 +0200
Subject: [PATCH] selftests: forwarding: ethtool_mm: support devices that don't
support pmac stats
Some devices do not support individual 'pmac' and 'emac' stats.
For such devices, resort to 'aggregate' stats.
Signed-off-by: Roger Quadros <rogerq@kernel.org>
---
tools/testing/selftests/net/forwarding/ethtool_mm.sh | 7 +++++++
1 file changed, 7 insertions(+)
@@ -26,6 +26,13 @@ traffic_test()localdelta=before=$(ethtool_std_stats_get$if"eth-mac""FramesTransmittedOK"$src)+# some devices don't support individual pmac/emac stats,+# use aggregate stats for them.+if["$before"==null];then+src="aggregate"+before=$(ethtool_std_stats_get$if"eth-mac""FramesTransmittedOO+K" $src)+fi$MZ$if-q-c$num_pkts-p64-bbcast-tip-R$PREEMPTIBLE_PRIO
I don't know, does it sound like it is related?
config TI_AM65_CPSW_TAS
bool "Enable TAS offload in AM65 CPSW"
depends on TI_K3_AM65_CPSW_NUSS && NET_SCH_TAPRIO && TI_K3_AM65_CPTS
help
Say y here to support Time Aware Shaper(TAS) offload in AM65 CPSW.
AM65 CPSW hardware supports Enhanced Scheduled Traffic (EST)
defined in IEEE 802.1Q 2018. The EST scheduler runs on CPTS and the
TAS/EST schedule is updated in the Fetch RAM memory of the CPSW.
From: Vladimir Oltean <vladimir.oltean@nxp.com> Date: 2023-12-11 12:12:47
On Fri, Dec 08, 2023 at 02:33:00PM +0200, Roger Quadros wrote:
But,
bool __ethtool_dev_mm_supported(struct net_device *dev)
{
const struct ethtool_ops *ops = dev->ethtool_ops;
struct ethtool_mm_state state = {};
int ret = -EOPNOTSUPP;
if (ops && ops->get_mm)
ret = ops->get_mm(dev, &state);
return !ret;
}
So looks like it is better to not define get_mm/set_mm if CONFIG_TI_AM65_CPSW_TAS is disabled.
Why not? __ethtool_dev_mm_supported() returns true if os->get_mm() is
implemented and returns 0. You return -EOPNOTSUPP, and that's different
from 0.
From: Roger Quadros <rogerq@kernel.org> Date: 2023-12-11 12:14:18
On 11/12/2023 14:12, Vladimir Oltean wrote:
On Fri, Dec 08, 2023 at 02:33:00PM +0200, Roger Quadros wrote:
quoted
But,
bool __ethtool_dev_mm_supported(struct net_device *dev)
{
const struct ethtool_ops *ops = dev->ethtool_ops;
struct ethtool_mm_state state = {};
int ret = -EOPNOTSUPP;
if (ops && ops->get_mm)
ret = ops->get_mm(dev, &state);
return !ret;
}
So looks like it is better to not define get_mm/set_mm if CONFIG_TI_AM65_CPSW_TAS is disabled.
Why not? __ethtool_dev_mm_supported() returns true if os->get_mm() is
implemented and returns 0. You return -EOPNOTSUPP, and that's different
from 0.
Yes, I realized it eventually. Better to define it and return -EOPNOTSUPP if
CONFIG_TI_AM65_CPSW_TAS is not enabled.
--
cheers,
-roger
I don't know, does it sound like it is related?
config TI_AM65_CPSW_TAS
bool "Enable TAS offload in AM65 CPSW"
depends on TI_K3_AM65_CPSW_NUSS && NET_SCH_TAPRIO && TI_K3_AM65_CPTS
help
Say y here to support Time Aware Shaper(TAS) offload in AM65 CPSW.
AM65 CPSW hardware supports Enhanced Scheduled Traffic (EST)
defined in IEEE 802.1Q 2018. The EST scheduler runs on CPTS and the
TAS/EST schedule is updated in the Fetch RAM memory of the CPSW.
The config option mentions only about TAS/EST 802.1Qbv.
Maybe it needs to be extended to include IET/Frame-preeption 802.1Qbu as well?
This is the simplest way as the file am65-cpsw-qos.c can be completely omitted if
TI_AM65_CPSW_TSN is not set.
--
cheers,
-roger
From: Vladimir Oltean <vladimir.oltean@nxp.com> Date: 2023-12-11 13:26:26
On Mon, Dec 11, 2023 at 02:25:35PM +0200, Roger Quadros wrote:
The config option mentions only about TAS/EST 802.1Qbv.
Maybe it needs to be extended to include IET/Frame-preeption 802.1Qbu as well?
This is the simplest way as the file am65-cpsw-qos.c can be completely omitted if
TI_AM65_CPSW_TSN is not set.
As long as you need to look no further than in "make menuconfig" to
figure out what you're enabling, it should be fine.
Furthermore, some consistency between the file name (-qos.c) and the
Kconfig option (_TAS/_TSN) would be nice.
From: Vladimir Oltean <vladimir.oltean@nxp.com> Date: 2023-12-11 13:29:08
On Fri, Dec 08, 2023 at 03:43:45PM +0200, Roger Quadros wrote:
quoted hunk
How do the below 2 patches look to resolve this?
From af2a8503dc04c54d6eaf50954628009aba54e2c8 Mon Sep 17 00:00:00 2001
From: Roger Quadros <rogerq@kernel.org>
Date: Fri, 8 Dec 2023 15:11:06 +0200
Subject: [PATCH] net: ethernet: ti: am65-cpsw: Fix get_eth_mac_stats
We do not support individual stats for PMAC and EMAC so
report only aggregate stats.
Fixes: 67372d7a85fcd ("net: ethernet: am65-cpsw: Add standard Ethernet MAC stats to ethtool")
Signed-off-by: Roger Quadros <rogerq@kernel.org>
---
drivers/net/ethernet/ti/am65-cpsw-ethtool.c | 37 ++++++++++++---------
1 file changed, 22 insertions(+), 15 deletions(-)
if (s->src != ETHTOOL_MAC_STATS_SRC_AGGREGATE)
return;
Also, again, tabs mixed with spaces. What editor are you using, notepad?
quoted hunk
static int am65_cpsw_get_ethtool_ts_info(struct net_device *ndev,
base-commit: a78e0a2c4353d6c100e45c5ef738113bf2d0fda5
--
2.34.1
From 0b20d8b8ef110d886396ee2486f3a9e20170cc85 Mon Sep 17 00:00:00 2001
From: Roger Quadros <rogerq@kernel.org>
Date: Fri, 8 Dec 2023 15:38:57 +0200
Subject: [PATCH] selftests: forwarding: ethtool_mm: support devices that don't
support pmac stats
Some devices do not support individual 'pmac' and 'emac' stats.
For such devices, resort to 'aggregate' stats.
Signed-off-by: Roger Quadros <rogerq@kernel.org>
---
tools/testing/selftests/net/forwarding/ethtool_mm.sh | 7 +++++++
1 file changed, 7 insertions(+)
@@ -26,6 +26,13 @@ traffic_test()localdelta=before=$(ethtool_std_stats_get$if"eth-mac""FramesTransmittedOK"$src)+# some devices don't support individual pmac/emac stats,+# use aggregate stats for them.+if["$before"==null];then+src="aggregate"+before=$(ethtool_std_stats_get$if"eth-mac""FramesTransmittedOO+K" $src)+fi$MZ$if-q-c$num_pkts-p64-bbcast-tip-R$PREEMPTIBLE_PRIO
From: Roger Quadros <rogerq@kernel.org> Date: 2023-12-11 13:59:49
On 11/12/2023 15:29, Vladimir Oltean wrote:
On Fri, Dec 08, 2023 at 03:43:45PM +0200, Roger Quadros wrote:
quoted
How do the below 2 patches look to resolve this?
From af2a8503dc04c54d6eaf50954628009aba54e2c8 Mon Sep 17 00:00:00 2001
From: Roger Quadros <rogerq@kernel.org>
Date: Fri, 8 Dec 2023 15:11:06 +0200
Subject: [PATCH] net: ethernet: ti: am65-cpsw: Fix get_eth_mac_stats
We do not support individual stats for PMAC and EMAC so
report only aggregate stats.
Fixes: 67372d7a85fcd ("net: ethernet: am65-cpsw: Add standard Ethernet MAC stats to ethtool")
Signed-off-by: Roger Quadros <rogerq@kernel.org>
---
drivers/net/ethernet/ti/am65-cpsw-ethtool.c | 37 ++++++++++++---------
1 file changed, 22 insertions(+), 15 deletions(-)
if (s->src != ETHTOOL_MAC_STATS_SRC_AGGREGATE)
return;
Is better.
Also, again, tabs mixed with spaces. What editor are you using, notepad?
I'm using vim but I didn't run checkpatch on it before pasting
it here for quick feedback.
quoted
static int am65_cpsw_get_ethtool_ts_info(struct net_device *ndev,
base-commit: a78e0a2c4353d6c100e45c5ef738113bf2d0fda5
--
2.34.1
From 0b20d8b8ef110d886396ee2486f3a9e20170cc85 Mon Sep 17 00:00:00 2001
From: Roger Quadros <rogerq@kernel.org>
Date: Fri, 8 Dec 2023 15:38:57 +0200
Subject: [PATCH] selftests: forwarding: ethtool_mm: support devices that don't
support pmac stats
Some devices do not support individual 'pmac' and 'emac' stats.
For such devices, resort to 'aggregate' stats.
Signed-off-by: Roger Quadros <rogerq@kernel.org>
---
tools/testing/selftests/net/forwarding/ethtool_mm.sh | 7 +++++++
1 file changed, 7 insertions(+)
@@ -26,6 +26,13 @@ traffic_test()localdelta=before=$(ethtool_std_stats_get$if"eth-mac""FramesTransmittedOK"$src)+# some devices don't support individual pmac/emac stats,+# use aggregate stats for them.+if["$before"==null];then+src="aggregate"+before=$(ethtool_std_stats_get$if"eth-mac""FramesTransmittedOO+K" $src)+fi$MZ$if-q-c$num_pkts-p64-bbcast-tip-R$PREEMPTIBLE_PRIO