staging: dpaa2-switch: small updates and fixes
cover staging: dpaa2-switch: small updates and fixes
From: Ioana Ciornei <[email protected]>
This patch set is just a small set of fixes and an update on the ethtool counters exported by the dpaa2-switch driver.
Ioana Ciornei (2):
staging: dpaa2-switch: make sure that the VLAN is not already
configured
staging: dpaa2-switch: pack the firmware command structures
Ionut-robert Aron (1):
staging: dpaa2-switch: export the 'no buffer' counter in ethtool
drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h | 10 +++++++--- drivers/staging/fsl-dpaa2/ethsw/dpsw.h | 6 ++++-- drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c | 2 +- drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 9 ++++++++- 4 files changed, 20 insertions(+), 7 deletions(-)
Signature · 1 line
2.28.0
PATCH 1/3 staging: dpaa2-switch: export the 'no buffer' counter in ethtool
From: Ionut-robert Aron <[email protected]>
Export the DPSW_CNT_ING_NO_BUFFER_DISCARD counter in ethtool for each switch interface. This is useful for debugging purposes.
--- drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h | 8 +++++--- drivers/staging/fsl-dpaa2/ethsw/dpsw.h | 6 ++++-- drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-)
drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h +5 -3
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright 2014-2016 Freescale Semiconductor Inc. -* Copyright 2017-2018 NXP +* Copyright 2017-2020 NXP * */
@@ -10,12 +10,14 @@/* DPSW Version */ #define DPSW_VER_MAJOR 8 -#define DPSW_VER_MINOR 1 +#define DPSW_VER_MINOR 5#define DPSW_CMD_BASE_VERSION 1 +#define DPSW_CMD_VERSION_2 2#define DPSW_CMD_ID_OFFSET 4#define DPSW_CMD_ID (id) (((id) << DPSW_CMD_ID_OFFSET) | DPSW_CMD_BASE_VERSION) +#define DPSW_CMD_V2 (id) (((id) << DPSW_CMD_ID_OFFSET) | DPSW_CMD_VERSION_2)/* Command IDs */ #define DPSW_CMDID_CLOSE DPSW_CMD_ID(0x800)
@@ -38,7 +40,7 @@#define DPSW_CMDID_IF_SET_TCI DPSW_CMD_ID(0x030)#define DPSW_CMDID_IF_SET_STP DPSW_CMD_ID(0x031) -#define DPSW_CMDID_IF_GET_COUNTER DPSW_CMD_ID(0x034) +#define DPSW_CMDID_IF_GET_COUNTER DPSW_CMD_V2(0x034)#define DPSW_CMDID_IF_ENABLE DPSW_CMD_ID(0x03D)#define DPSW_CMDID_IF_DISABLE DPSW_CMD_ID(0x03E)
drivers/staging/fsl-dpaa2/ethsw/dpsw.h +4 -2
@@ -334,9 +334,10 @@ enum dpsw_accepted_frames {* @DPSW_CNT_ING_BCAST_FRAME: Counts ingress broadcast frames * @DPSW_CNT_ING_BCAST_BYTES: Counts ingress broadcast bytes * @DPSW_CNT_EGR_FRAME: Counts egress frames -* @DPSW_CNT_EGR_BYTE: Counts eEgress bytes +* @DPSW_CNT_EGR_BYTE: Counts egress bytes * @DPSW_CNT_EGR_FRAME_DISCARD: Counts discarded egress frames * @DPSW_CNT_EGR_STP_FRAME_DISCARD: Counts egress STP discarded frames +* @DPSW_CNT_ING_NO_BUFF_DISCARD: Counts ingress no buffer discarded frames */ enum dpsw_counter {DPSW_CNT_ING_FRAME =0x0 ,
@@ -350,7 +351,8 @@ enum dpsw_counter {DPSW_CNT_EGR_FRAME =0x8 ,DPSW_CNT_EGR_BYTE =0x9 ,DPSW_CNT_EGR_FRAME_DISCARD =0xa , -DPSW_CNT_EGR_STP_FRAME_DISCARD =0xb +DPSW_CNT_EGR_STP_FRAME_DISCARD =0xb , + DPSW_CNT_ING_NO_BUFF_DISCARD = 0xc, }; int dpsw_if_get_counter(struct fsl_mc_io *mc_io,
drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c +1 -1
@@ -24,7 +24,7 @@ static struct { {DPSW_CNT_EGR_FRAME, "tx frames"}, {DPSW_CNT_EGR_BYTE, "tx bytes"}, {DPSW_CNT_EGR_FRAME_DISCARD, "tx discarded frames"}, - + {DPSW_CNT_ING_NO_BUFF_DISCARD, "rx discarded no buffer frames"}, };#define DPAA2_SWITCH_NUM_COUNTERS ARRAY_SIZE(dpaa2_switch_ethtool_counters)
Signature · 1 line
2.28.0
PATCH 2/3 staging: dpaa2-switch: make sure that the VLAN is not already configured
In reply to Ioana CiorneiFrom: Ioana Ciornei <[email protected]>
When in the PREPARE state of a switchdev transaction, check if the requested VLAN is not already configured on the switch port. This keeps us from getting into a WARNING as below.
[ 1389.683296] dpaa2_ethsw dpsw.0 eth0: VLAN 2 already configured [ 1389.689125] ------------[ cut here ]------------ [ 1389.694084] eth0: Commit of object (id=1) failed. [ 1389.698863] WARNING: CPU: 0 PID: 613 at net/switchdev/switchdev.c:277 switchdev_port_obj_add_now+0xcc/0x110 [ 1389.708589] Modules linked in: [ 1389.711634] CPU: 0 PID: 613 Comm: bridge Not tainted 5.9.0-rc2-next-20200828-00112-g7172078477c5 #59 [ 1389.720753] Hardware name: NXP Layerscape LX2160ARDB (DT) [ 1389.726139] pstate: 40000005 (nZcv daif -PAN -UAO BTYPE=--) [ 1389.731698] pc : switchdev_port_obj_add_now+0xcc/0x110 [ 1389.736824] lr : switchdev_port_obj_add_now+0xcc/0x110
--- drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/staging/fsl-dpaa2/ethsw/ethsw.c +8 -1
@@ -984,10 +984,17 @@ static int dpaa2_switch_port_vlans_add(struct net_device *netdev,int vid, err =0 , new_vlans =0 ;if (switchdev_trans_ph_prepare (trans)) { -for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) +for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) {if (!port_priv->ethsw_data->vlans[vid]) new_vlans++; +/* Make sure that the VLAN is not already configured +* on the switch port +*/ +if (port_priv->vlans[vid] ÐSW_VLAN_MEMBER ) +return -EEXIST ; + } +/* Check if there is space for a new VLAN */ err =dpsw_get_attributes (ethsw->mc_io,0 , ethsw->dpsw_handle, ðsw->sw_attr);
Signature · 1 line
2.28.0
PATCH 3/3 staging: dpaa2-switch: pack the firmware command structures
In reply to Ioana CiorneiFrom: Ioana Ciornei <[email protected]>
The structures defined in the dpsw-cmd.h header file describe exactly the layout of commands accepted by the MC firmware. Make sure that all these structures are packed.
--- drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h | 2 ++ 1 file changed, 2 insertions(+)
drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h +2 -0
@@ -86,6 +86,7 @@#define dpsw_get_bit (var, bit) \ (((var) >> (bit)) & GENMASK(0, 0)) +#pragma pack(push, 1)struct dpsw_cmd_open {__le32 dpsw_id; };
@@ -385,4 +386,5 @@ struct dpsw_cmd_if_set_mac_addr { u8 mac_addr[6]; }; +#pragma pack(pop)#endif /* __FSL_DPSW_CMD_H */
Signature · 1 line
2.28.0