* [Patch v3 net-next 5/7] octeontx2-af: advertised link modes support on cgx [not found] <1612098665-187767-1-git-send-email-hkelam@marvell.com> @ 2021-01-31 13:11 ` Hariprasad Kelam 2021-01-31 13:11 ` [Patch v3 net-next 6/7] octeontx2-pf: ethtool physical link status Hariprasad Kelam ` (2 subsequent siblings) 3 siblings, 0 replies; 12+ messages in thread From: Hariprasad Kelam @ 2021-01-31 13:11 UTC (permalink / raw) To: netdev, linux-kernel Cc: kuba, davem, willemdebruijn.kernel, andrew, sgoutham, lcherian, gakula, jerinj, sbhatta, hkelam From: Christina Jacob <cjacob@marvell.com> CGX supports setting advertised link modes on physical link. This patch adds support to derive cgx mode from ethtool link mode and pass it to firmware to configure the same. Signed-off-by: Christina Jacob <cjacob@marvell.com> Signed-off-by: Sunil Goutham <sgoutham@marvell.com> Signed-off-by: Hariprasad Kelam <hkelam@marvell.com> --- drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 114 ++++++++++++++++++++- .../net/ethernet/marvell/octeontx2/af/cgx_fw_if.h | 32 +++++- drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 3 +- 3 files changed, 146 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c index 5b7d858..9c62129 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c @@ -14,6 +14,7 @@ #include <linux/pci.h> #include <linux/netdevice.h> #include <linux/etherdevice.h> +#include <linux/ethtool.h> #include <linux/phy.h> #include <linux/of.h> #include <linux/of_mdio.h> @@ -646,6 +647,7 @@ static inline void cgx_link_usertable_init(void) cgx_speed_mbps[CGX_LINK_25G] = 25000; cgx_speed_mbps[CGX_LINK_40G] = 40000; cgx_speed_mbps[CGX_LINK_50G] = 50000; + cgx_speed_mbps[CGX_LINK_80G] = 80000; cgx_speed_mbps[CGX_LINK_100G] = 100000; cgx_lmactype_string[LMAC_MODE_SGMII] = "SGMII"; @@ -693,6 +695,110 @@ static int cgx_link_usertable_index_map(int speed) return CGX_LINK_NONE; } +static void set_mod_args(struct cgx_set_link_mode_args *args, + u32 speed, u8 duplex, u8 autoneg, u64 mode) +{ + /* Fill default values incase of user did not pass + * valid parameters + */ + if (args->duplex == DUPLEX_UNKNOWN) + args->duplex = duplex; + if (args->speed == SPEED_UNKNOWN) + args->speed = speed; + if (args->an == AUTONEG_UNKNOWN) + args->an = autoneg; + args->mode = mode; + args->ports = 0; +} + +static void otx2_map_ethtool_link_modes(u64 bitmask, + struct cgx_set_link_mode_args *args) +{ + switch (bitmask) { + case ETHTOOL_LINK_MODE_10baseT_Half_BIT: + set_mod_args(args, 10, 1, 1, BIT_ULL(CGX_MODE_SGMII)); + break; + case ETHTOOL_LINK_MODE_10baseT_Full_BIT: + set_mod_args(args, 10, 0, 1, BIT_ULL(CGX_MODE_SGMII)); + break; + case ETHTOOL_LINK_MODE_100baseT_Half_BIT: + set_mod_args(args, 100, 1, 1, BIT_ULL(CGX_MODE_SGMII)); + break; + case ETHTOOL_LINK_MODE_100baseT_Full_BIT: + set_mod_args(args, 100, 0, 1, BIT_ULL(CGX_MODE_SGMII)); + break; + case ETHTOOL_LINK_MODE_1000baseT_Half_BIT: + set_mod_args(args, 1000, 1, 1, BIT_ULL(CGX_MODE_SGMII)); + break; + case ETHTOOL_LINK_MODE_1000baseT_Full_BIT: + set_mod_args(args, 1000, 0, 1, BIT_ULL(CGX_MODE_SGMII)); + break; + case ETHTOOL_LINK_MODE_1000baseX_Full_BIT: + set_mod_args(args, 1000, 0, 0, BIT_ULL(CGX_MODE_1000_BASEX)); + break; + case ETHTOOL_LINK_MODE_10000baseT_Full_BIT: + set_mod_args(args, 1000, 0, 1, BIT_ULL(CGX_MODE_QSGMII)); + break; + case ETHTOOL_LINK_MODE_10000baseSR_Full_BIT: + set_mod_args(args, 10000, 0, 0, BIT_ULL(CGX_MODE_10G_C2C)); + break; + case ETHTOOL_LINK_MODE_10000baseLR_Full_BIT: + set_mod_args(args, 10000, 0, 0, BIT_ULL(CGX_MODE_10G_C2M)); + break; + case ETHTOOL_LINK_MODE_10000baseKR_Full_BIT: + set_mod_args(args, 10000, 0, 1, BIT_ULL(CGX_MODE_10G_KR)); + break; + case ETHTOOL_LINK_MODE_25000baseSR_Full_BIT: + set_mod_args(args, 25000, 0, 0, BIT_ULL(CGX_MODE_25G_C2C)); + break; + case ETHTOOL_LINK_MODE_25000baseCR_Full_BIT: + set_mod_args(args, 25000, 0, 1, BIT_ULL(CGX_MODE_25G_CR)); + break; + case ETHTOOL_LINK_MODE_25000baseKR_Full_BIT: + set_mod_args(args, 25000, 0, 1, BIT_ULL(CGX_MODE_25G_KR)); + break; + case ETHTOOL_LINK_MODE_40000baseSR4_Full_BIT: + set_mod_args(args, 40000, 0, 0, BIT_ULL(CGX_MODE_40G_C2C)); + break; + case ETHTOOL_LINK_MODE_40000baseLR4_Full_BIT: + set_mod_args(args, 40000, 0, 0, BIT_ULL(CGX_MODE_40G_C2M)); + break; + case ETHTOOL_LINK_MODE_40000baseCR4_Full_BIT: + set_mod_args(args, 40000, 0, 1, BIT_ULL(CGX_MODE_40G_CR4)); + break; + case ETHTOOL_LINK_MODE_40000baseKR4_Full_BIT: + set_mod_args(args, 40000, 0, 1, BIT_ULL(CGX_MODE_40G_KR4)); + break; + case ETHTOOL_LINK_MODE_50000baseSR_Full_BIT: + set_mod_args(args, 50000, 0, 0, BIT_ULL(CGX_MODE_50G_C2C)); + break; + case ETHTOOL_LINK_MODE_50000baseLR_ER_FR_Full_BIT: + set_mod_args(args, 50000, 0, 0, BIT_ULL(CGX_MODE_50G_C2M)); + break; + case ETHTOOL_LINK_MODE_50000baseCR_Full_BIT: + set_mod_args(args, 50000, 0, 1, BIT_ULL(CGX_MODE_50G_CR)); + break; + case ETHTOOL_LINK_MODE_50000baseKR_Full_BIT: + set_mod_args(args, 50000, 0, 1, BIT_ULL(CGX_MODE_50G_KR)); + break; + case ETHTOOL_LINK_MODE_100000baseSR4_Full_BIT: + set_mod_args(args, 100000, 0, 0, BIT_ULL(CGX_MODE_100G_C2C)); + break; + case ETHTOOL_LINK_MODE_100000baseLR4_ER4_Full_BIT: + set_mod_args(args, 100000, 0, 0, BIT_ULL(CGX_MODE_100G_C2M)); + break; + case ETHTOOL_LINK_MODE_100000baseCR4_Full_BIT: + set_mod_args(args, 100000, 0, 1, BIT_ULL(CGX_MODE_100G_CR4)); + break; + case ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT: + set_mod_args(args, 100000, 0, 1, BIT_ULL(CGX_MODE_100G_KR4)); + break; + default: + set_mod_args(args, 0, 1, 0, BIT_ULL(CGX_MODE_MAX)); + break; + } +} + static inline void link_status_user_format(u64 lstat, struct cgx_link_user_info *linfo, struct cgx *cgx, u8 lmac_id) @@ -887,13 +993,19 @@ int cgx_set_link_mode(void *cgxd, struct cgx_set_link_mode_args args, if (!cgx) return -ENODEV; + if (args.mode) + otx2_map_ethtool_link_modes(args.mode, &args); + if (!args.speed && args.duplex && !args.an) + return -EINVAL; + req = FIELD_SET(CMDREG_ID, CGX_CMD_MODE_CHANGE, req); req = FIELD_SET(CMDMODECHANGE_SPEED, cgx_link_usertable_index_map(args.speed), req); req = FIELD_SET(CMDMODECHANGE_DUPLEX, args.duplex, req); req = FIELD_SET(CMDMODECHANGE_AN, args.an, req); req = FIELD_SET(CMDMODECHANGE_PORT, args.ports, req); - req = FIELD_SET(CMDMODECHANGE_FLAGS, args.flags, req); + req = FIELD_SET(CMDMODECHANGE_FLAGS, args.mode, req); + return cgx_fwi_cmd_generic(req, &resp, cgx, lmac_id); } int cgx_set_fec(u64 fec, int cgx_id, int lmac_id) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cgx_fw_if.h b/drivers/net/ethernet/marvell/octeontx2/af/cgx_fw_if.h index 70610e7..dde2bd0 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/cgx_fw_if.h +++ b/drivers/net/ethernet/marvell/octeontx2/af/cgx_fw_if.h @@ -70,6 +70,36 @@ enum cgx_link_speed { CGX_LINK_SPEED_MAX, }; +enum CGX_MODE_ { + CGX_MODE_SGMII, + CGX_MODE_1000_BASEX, + CGX_MODE_QSGMII, + CGX_MODE_10G_C2C, + CGX_MODE_10G_C2M, + CGX_MODE_10G_KR, + CGX_MODE_20G_C2C, + CGX_MODE_25G_C2C, + CGX_MODE_25G_C2M, + CGX_MODE_25G_2_C2C, + CGX_MODE_25G_CR, + CGX_MODE_25G_KR, + CGX_MODE_40G_C2C, + CGX_MODE_40G_C2M, + CGX_MODE_40G_CR4, + CGX_MODE_40G_KR4, + CGX_MODE_40GAUI_C2C, + CGX_MODE_50G_C2C, + CGX_MODE_50G_C2M, + CGX_MODE_50G_4_C2C, + CGX_MODE_50G_CR, + CGX_MODE_50G_KR, + CGX_MODE_80GAUI_C2C, + CGX_MODE_100G_C2C, + CGX_MODE_100G_C2M, + CGX_MODE_100G_CR4, + CGX_MODE_100G_KR4, + CGX_MODE_MAX /* = 29 */ +}; /* REQUEST ID types. Input to firmware */ enum cgx_cmd_id { CGX_CMD_NONE, @@ -231,6 +261,6 @@ struct cgx_lnk_sts { #define CMDMODECHANGE_DUPLEX GENMASK_ULL(12, 12) #define CMDMODECHANGE_AN GENMASK_ULL(13, 13) #define CMDMODECHANGE_PORT GENMASK_ULL(21, 14) -#define CMDMODECHANGE_FLAGS GENMASK_ULL(29, 22) +#define CMDMODECHANGE_FLAGS GENMASK_ULL(63, 22) #endif /* __CGX_FW_INTF_H__ */ diff --git a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h index a050902..05a6da2 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h +++ b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h @@ -462,10 +462,11 @@ struct cgx_set_link_mode_args { u8 duplex; u8 an; u8 ports; - u8 flags; + u64 mode; }; struct cgx_set_link_mode_req { +#define AUTONEG_UNKNOWN 0xff struct mbox_msghdr hdr; struct cgx_set_link_mode_args args; }; -- 2.7.4 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Patch v3 net-next 6/7] octeontx2-pf: ethtool physical link status [not found] <1612098665-187767-1-git-send-email-hkelam@marvell.com> 2021-01-31 13:11 ` [Patch v3 net-next 5/7] octeontx2-af: advertised link modes support on cgx Hariprasad Kelam @ 2021-01-31 13:11 ` Hariprasad Kelam 2021-02-03 1:23 ` Jakub Kicinski 2021-02-01 0:54 ` [Patch v3 net-next 0/7] ethtool support for fec and link configuration Willem de Bruijn [not found] ` <1612098665-187767-8-git-send-email-hkelam@marvell.com> 3 siblings, 1 reply; 12+ messages in thread From: Hariprasad Kelam @ 2021-01-31 13:11 UTC (permalink / raw) To: netdev, linux-kernel Cc: kuba, davem, willemdebruijn.kernel, andrew, sgoutham, lcherian, gakula, jerinj, sbhatta, hkelam From: Christina Jacob <cjacob@marvell.com> Register get_link_ksettings callback to get link status information from the driver. As virtual function (vf) shares same physical link same API is used for both the drivers and for loop back drivers simply returns the fixed values as its does not have physical link. ethtool eth3 Settings for eth3: Supported ports: [ ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Half 1000baseT/Full 10000baseKR/Full 1000baseX/Full Supports auto-negotiation: No Supported FEC modes: BaseR RS Advertised link modes: Not reported Advertised pause frame use: No Advertised auto-negotiation: No Advertised FEC modes: None ethtool lbk0 Settings for lbk0: Speed: 100000Mb/s Duplex: Full Signed-off-by: Christina Jacob <cjacob@marvell.com> Signed-off-by: Sunil Goutham <sgoutham@marvell.com> Signed-off-by: Hariprasad Kelam <hkelam@marvell.com> --- .../ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 151 +++++++++++++++++++++ 1 file changed, 151 insertions(+) diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c index e5b1a57..d637815 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c @@ -14,6 +14,7 @@ #include <linux/etherdevice.h> #include <linux/log2.h> #include <linux/net_tstamp.h> +#include <linux/linkmode.h> #include "otx2_common.h" #include "otx2_ptp.h" @@ -32,6 +33,24 @@ struct otx2_stat { .index = offsetof(struct otx2_dev_stats, stat) / sizeof(u64), \ } +/* Physical link config */ +#define OTX2_ETHTOOL_SUPPORTED_MODES 0x638CCBF //110001110001100110010111111 +#define OTX2_RESERVED_ETHTOOL_LINK_MODE 0 + +static const int otx2_sgmii_features_array[6] = { + ETHTOOL_LINK_MODE_10baseT_Half_BIT, + ETHTOOL_LINK_MODE_10baseT_Full_BIT, + ETHTOOL_LINK_MODE_100baseT_Half_BIT, + ETHTOOL_LINK_MODE_100baseT_Full_BIT, + ETHTOOL_LINK_MODE_1000baseT_Half_BIT, + ETHTOOL_LINK_MODE_1000baseT_Full_BIT, +}; + +enum link_mode { + OTX2_MODE_SUPPORTED, + OTX2_MODE_ADVERTISED +}; + static const struct otx2_stat otx2_dev_stats[] = { OTX2_DEV_STAT(rx_ucast_frames), OTX2_DEV_STAT(rx_bcast_frames), @@ -1034,6 +1053,123 @@ static int otx2_set_fecparam(struct net_device *netdev, return err; } +static void otx2_get_fec_info(u64 index, int req_mode, + struct ethtool_link_ksettings *link_ksettings) +{ + __ETHTOOL_DECLARE_LINK_MODE_MASK(otx2_fec_modes) = { 0, }; + + switch (index) { + case OTX2_FEC_NONE: + linkmode_set_bit(ETHTOOL_LINK_MODE_FEC_NONE_BIT, otx2_fec_modes); + break; + case OTX2_FEC_BASER: + linkmode_set_bit(ETHTOOL_LINK_MODE_FEC_BASER_BIT, otx2_fec_modes); + break; + case OTX2_FEC_RS: + linkmode_set_bit(ETHTOOL_LINK_MODE_FEC_RS_BIT, otx2_fec_modes); + break; + case OTX2_FEC_BASER | OTX2_FEC_RS: + linkmode_set_bit(ETHTOOL_LINK_MODE_FEC_BASER_BIT, otx2_fec_modes); + linkmode_set_bit(ETHTOOL_LINK_MODE_FEC_RS_BIT, otx2_fec_modes); + break; + } + + /* Add fec modes to existing modes */ + if (req_mode == OTX2_MODE_ADVERTISED) + linkmode_or(link_ksettings->link_modes.advertising, + link_ksettings->link_modes.advertising, + otx2_fec_modes); + else + linkmode_or(link_ksettings->link_modes.supported, + link_ksettings->link_modes.supported, + otx2_fec_modes); +} + +static void otx2_get_link_mode_info(u64 link_mode_bmap, + bool req_mode, + struct ethtool_link_ksettings + *link_ksettings) +{ + __ETHTOOL_DECLARE_LINK_MODE_MASK(otx2_link_modes) = { 0, }; + u8 bit; + + /* CGX link modes to Ethtool link mode mapping */ + const int cgx_link_mode[27] = { + 0, /* SGMII Mode */ + ETHTOOL_LINK_MODE_1000baseX_Full_BIT, + ETHTOOL_LINK_MODE_10000baseT_Full_BIT, + ETHTOOL_LINK_MODE_10000baseSR_Full_BIT, + ETHTOOL_LINK_MODE_10000baseLR_Full_BIT, + ETHTOOL_LINK_MODE_10000baseKR_Full_BIT, + OTX2_RESERVED_ETHTOOL_LINK_MODE, + ETHTOOL_LINK_MODE_25000baseSR_Full_BIT, + OTX2_RESERVED_ETHTOOL_LINK_MODE, + OTX2_RESERVED_ETHTOOL_LINK_MODE, + ETHTOOL_LINK_MODE_25000baseCR_Full_BIT, + ETHTOOL_LINK_MODE_25000baseKR_Full_BIT, + ETHTOOL_LINK_MODE_40000baseSR4_Full_BIT, + ETHTOOL_LINK_MODE_40000baseLR4_Full_BIT, + ETHTOOL_LINK_MODE_40000baseCR4_Full_BIT, + ETHTOOL_LINK_MODE_40000baseKR4_Full_BIT, + OTX2_RESERVED_ETHTOOL_LINK_MODE, + ETHTOOL_LINK_MODE_50000baseSR_Full_BIT, + OTX2_RESERVED_ETHTOOL_LINK_MODE, + ETHTOOL_LINK_MODE_50000baseLR_ER_FR_Full_BIT, + ETHTOOL_LINK_MODE_50000baseCR_Full_BIT, + ETHTOOL_LINK_MODE_50000baseKR_Full_BIT, + OTX2_RESERVED_ETHTOOL_LINK_MODE, + ETHTOOL_LINK_MODE_100000baseSR4_Full_BIT, + ETHTOOL_LINK_MODE_100000baseLR4_ER4_Full_BIT, + ETHTOOL_LINK_MODE_100000baseCR4_Full_BIT, + ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT + }; + + link_mode_bmap = link_mode_bmap & OTX2_ETHTOOL_SUPPORTED_MODES; + + for_each_set_bit(bit, (unsigned long *)&link_mode_bmap, 27) { + /* SGMII mode is set */ + if (bit == 0) + linkmode_set_bit_array(otx2_sgmii_features_array, + ARRAY_SIZE(otx2_sgmii_features_array), + otx2_link_modes); + else + linkmode_set_bit(cgx_link_mode[bit], otx2_link_modes); + } + + if (req_mode == OTX2_MODE_ADVERTISED) + linkmode_copy(link_ksettings->link_modes.advertising, otx2_link_modes); + else + linkmode_copy(link_ksettings->link_modes.supported, otx2_link_modes); +} + +static int otx2_get_link_ksettings(struct net_device *netdev, + struct ethtool_link_ksettings *cmd) +{ + struct otx2_nic *pfvf = netdev_priv(netdev); + struct cgx_fw_data *rsp = NULL; + + cmd->base.duplex = pfvf->linfo.full_duplex; + cmd->base.speed = pfvf->linfo.speed; + cmd->base.autoneg = pfvf->linfo.an; + + rsp = otx2_get_fwdata(pfvf); + if (IS_ERR(rsp)) + return PTR_ERR(rsp); + + if (rsp->fwdata.supported_an) + ethtool_link_ksettings_add_link_mode(cmd, + supported, + Autoneg); + + otx2_get_link_mode_info(rsp->fwdata.advertised_link_modes, OTX2_MODE_ADVERTISED, cmd); + otx2_get_fec_info(rsp->fwdata.advertised_fec, OTX2_MODE_ADVERTISED, cmd); + + otx2_get_link_mode_info(rsp->fwdata.supported_link_modes, OTX2_MODE_SUPPORTED, cmd); + otx2_get_fec_info(rsp->fwdata.supported_fec, OTX2_MODE_SUPPORTED, cmd); + + return 0; +} + static const struct ethtool_ops otx2_ethtool_ops = { .supported_coalesce_params = ETHTOOL_COALESCE_USECS | ETHTOOL_COALESCE_MAX_FRAMES, @@ -1063,6 +1199,7 @@ static const struct ethtool_ops otx2_ethtool_ops = { .get_ts_info = otx2_get_ts_info, .get_fecparam = otx2_get_fecparam, .set_fecparam = otx2_set_fecparam, + .get_link_ksettings = otx2_get_link_ksettings, }; void otx2_set_ethtool_ops(struct net_device *netdev) @@ -1137,6 +1274,19 @@ static int otx2vf_get_sset_count(struct net_device *netdev, int sset) return otx2_n_dev_stats + otx2_n_drv_stats + qstats_count + 1; } +static int otx2vf_get_link_ksettings(struct net_device *netdev, + struct ethtool_link_ksettings *cmd) +{ + struct otx2_nic *pfvf = netdev_priv(netdev); + + if (is_otx2_lbkvf(pfvf->pdev)) { + cmd->base.duplex = DUPLEX_FULL; + cmd->base.speed = SPEED_100000; + } else { + return otx2_get_link_ksettings(netdev, cmd); + } + return 0; +} static const struct ethtool_ops otx2vf_ethtool_ops = { .supported_coalesce_params = ETHTOOL_COALESCE_USECS | ETHTOOL_COALESCE_MAX_FRAMES, @@ -1163,6 +1313,7 @@ static const struct ethtool_ops otx2vf_ethtool_ops = { .set_msglevel = otx2_set_msglevel, .get_pauseparam = otx2_get_pauseparam, .set_pauseparam = otx2_set_pauseparam, + .get_link_ksettings = otx2vf_get_link_ksettings, }; void otx2vf_set_ethtool_ops(struct net_device *netdev) -- 2.7.4 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [Patch v3 net-next 6/7] octeontx2-pf: ethtool physical link status 2021-01-31 13:11 ` [Patch v3 net-next 6/7] octeontx2-pf: ethtool physical link status Hariprasad Kelam @ 2021-02-03 1:23 ` Jakub Kicinski 0 siblings, 0 replies; 12+ messages in thread From: Jakub Kicinski @ 2021-02-03 1:23 UTC (permalink / raw) To: Hariprasad Kelam Cc: netdev, linux-kernel, davem, willemdebruijn.kernel, andrew, sgoutham, lcherian, gakula, jerinj, sbhatta On Sun, 31 Jan 2021 18:41:04 +0530 Hariprasad Kelam wrote: > From: Christina Jacob <cjacob@marvell.com> > > Register get_link_ksettings callback to get link status information > from the driver. As virtual function (vf) shares same physical link > same API is used for both the drivers and for loop back drivers > simply returns the fixed values as its does not have physical link. > > ethtool eth3 > Settings for eth3: > Supported ports: [ ] > Supported link modes: 10baseT/Half 10baseT/Full > 100baseT/Half 100baseT/Full > 1000baseT/Half 1000baseT/Full > 10000baseKR/Full > 1000baseX/Full > Supports auto-negotiation: No > Supported FEC modes: BaseR RS > Advertised link modes: Not reported > Advertised pause frame use: No > Advertised auto-negotiation: No > Advertised FEC modes: None > > ethtool lbk0 > Settings for lbk0: > Speed: 100000Mb/s > Duplex: Full > > Signed-off-by: Christina Jacob <cjacob@marvell.com> > Signed-off-by: Sunil Goutham <sgoutham@marvell.com> > Signed-off-by: Hariprasad Kelam <hkelam@marvell.com> > --- > .../ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 151 +++++++++++++++++++++ > 1 file changed, 151 insertions(+) > > diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c > index e5b1a57..d637815 100644 > --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c > +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c > @@ -14,6 +14,7 @@ > #include <linux/etherdevice.h> > #include <linux/log2.h> > #include <linux/net_tstamp.h> > +#include <linux/linkmode.h> > > #include "otx2_common.h" > #include "otx2_ptp.h" > @@ -32,6 +33,24 @@ struct otx2_stat { > .index = offsetof(struct otx2_dev_stats, stat) / sizeof(u64), \ > } > > +/* Physical link config */ > +#define OTX2_ETHTOOL_SUPPORTED_MODES 0x638CCBF //110001110001100110010111111 > +#define OTX2_RESERVED_ETHTOOL_LINK_MODE 0 Just use 0 directly in the code. > +static const int otx2_sgmii_features_array[6] = { > + ETHTOOL_LINK_MODE_10baseT_Half_BIT, > + ETHTOOL_LINK_MODE_10baseT_Full_BIT, > + ETHTOOL_LINK_MODE_100baseT_Half_BIT, > + ETHTOOL_LINK_MODE_100baseT_Full_BIT, > + ETHTOOL_LINK_MODE_1000baseT_Half_BIT, > + ETHTOOL_LINK_MODE_1000baseT_Full_BIT, > +}; Why is this one up at the top of the file but other arrays are not? It seems to be used only in once function. > +enum link_mode { > + OTX2_MODE_SUPPORTED, > + OTX2_MODE_ADVERTISED > +}; > + > static const struct otx2_stat otx2_dev_stats[] = { > OTX2_DEV_STAT(rx_ucast_frames), > OTX2_DEV_STAT(rx_bcast_frames), > @@ -1034,6 +1053,123 @@ static int otx2_set_fecparam(struct net_device *netdev, > return err; > } > > +static void otx2_get_fec_info(u64 index, int req_mode, > + struct ethtool_link_ksettings *link_ksettings) > +{ > + __ETHTOOL_DECLARE_LINK_MODE_MASK(otx2_fec_modes) = { 0, }; > + > + switch (index) { > + case OTX2_FEC_NONE: > + linkmode_set_bit(ETHTOOL_LINK_MODE_FEC_NONE_BIT, otx2_fec_modes); > + break; > + case OTX2_FEC_BASER: > + linkmode_set_bit(ETHTOOL_LINK_MODE_FEC_BASER_BIT, otx2_fec_modes); > + break; > + case OTX2_FEC_RS: > + linkmode_set_bit(ETHTOOL_LINK_MODE_FEC_RS_BIT, otx2_fec_modes); > + break; > + case OTX2_FEC_BASER | OTX2_FEC_RS: > + linkmode_set_bit(ETHTOOL_LINK_MODE_FEC_BASER_BIT, otx2_fec_modes); > + linkmode_set_bit(ETHTOOL_LINK_MODE_FEC_RS_BIT, otx2_fec_modes); > + break; > + } > + > + /* Add fec modes to existing modes */ > + if (req_mode == OTX2_MODE_ADVERTISED) > + linkmode_or(link_ksettings->link_modes.advertising, > + link_ksettings->link_modes.advertising, > + otx2_fec_modes); > + else > + linkmode_or(link_ksettings->link_modes.supported, > + link_ksettings->link_modes.supported, > + otx2_fec_modes); > +} > + > +static void otx2_get_link_mode_info(u64 link_mode_bmap, > + bool req_mode, > + struct ethtool_link_ksettings > + *link_ksettings) > +{ > + __ETHTOOL_DECLARE_LINK_MODE_MASK(otx2_link_modes) = { 0, }; > + u8 bit; > + No empty lines in the middle of variable declarations. > + /* CGX link modes to Ethtool link mode mapping */ > + const int cgx_link_mode[27] = { > + 0, /* SGMII Mode */ > + ETHTOOL_LINK_MODE_1000baseX_Full_BIT, > + ETHTOOL_LINK_MODE_10000baseT_Full_BIT, > + ETHTOOL_LINK_MODE_10000baseSR_Full_BIT, > + ETHTOOL_LINK_MODE_10000baseLR_Full_BIT, > + ETHTOOL_LINK_MODE_10000baseKR_Full_BIT, > + OTX2_RESERVED_ETHTOOL_LINK_MODE, > + ETHTOOL_LINK_MODE_25000baseSR_Full_BIT, > + OTX2_RESERVED_ETHTOOL_LINK_MODE, > + OTX2_RESERVED_ETHTOOL_LINK_MODE, > + ETHTOOL_LINK_MODE_25000baseCR_Full_BIT, > + ETHTOOL_LINK_MODE_25000baseKR_Full_BIT, > + ETHTOOL_LINK_MODE_40000baseSR4_Full_BIT, > + ETHTOOL_LINK_MODE_40000baseLR4_Full_BIT, > + ETHTOOL_LINK_MODE_40000baseCR4_Full_BIT, > + ETHTOOL_LINK_MODE_40000baseKR4_Full_BIT, > + OTX2_RESERVED_ETHTOOL_LINK_MODE, > + ETHTOOL_LINK_MODE_50000baseSR_Full_BIT, > + OTX2_RESERVED_ETHTOOL_LINK_MODE, > + ETHTOOL_LINK_MODE_50000baseLR_ER_FR_Full_BIT, > + ETHTOOL_LINK_MODE_50000baseCR_Full_BIT, > + ETHTOOL_LINK_MODE_50000baseKR_Full_BIT, > + OTX2_RESERVED_ETHTOOL_LINK_MODE, > + ETHTOOL_LINK_MODE_100000baseSR4_Full_BIT, > + ETHTOOL_LINK_MODE_100000baseLR4_ER4_Full_BIT, > + ETHTOOL_LINK_MODE_100000baseCR4_Full_BIT, > + ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT > + }; > + > + link_mode_bmap = link_mode_bmap & OTX2_ETHTOOL_SUPPORTED_MODES; > + > + for_each_set_bit(bit, (unsigned long *)&link_mode_bmap, 27) { > + /* SGMII mode is set */ > + if (bit == 0) Double spaces x2 > + linkmode_set_bit_array(otx2_sgmii_features_array, > + ARRAY_SIZE(otx2_sgmii_features_array), > + otx2_link_modes); > + else > + linkmode_set_bit(cgx_link_mode[bit], otx2_link_modes); > + } > + > + if (req_mode == OTX2_MODE_ADVERTISED) > + linkmode_copy(link_ksettings->link_modes.advertising, otx2_link_modes); > + else > + linkmode_copy(link_ksettings->link_modes.supported, otx2_link_modes); > +} > + otx2_get_link_mode_info(rsp->fwdata.advertised_link_modes, OTX2_MODE_ADVERTISED, cmd); > + otx2_get_fec_info(rsp->fwdata.advertised_fec, OTX2_MODE_ADVERTISED, cmd); > + > + otx2_get_link_mode_info(rsp->fwdata.supported_link_modes, OTX2_MODE_SUPPORTED, cmd); > + otx2_get_fec_info(rsp->fwdata.supported_fec, OTX2_MODE_SUPPORTED, cmd); Wrap those lines please. > + return 0; > +} > +static int otx2vf_get_link_ksettings(struct net_device *netdev, > + struct ethtool_link_ksettings *cmd) > +{ > + struct otx2_nic *pfvf = netdev_priv(netdev); > + > + if (is_otx2_lbkvf(pfvf->pdev)) { > + cmd->base.duplex = DUPLEX_FULL; > + cmd->base.speed = SPEED_100000; > + } else { > + return otx2_get_link_ksettings(netdev, cmd); Double space ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Patch v3 net-next 0/7] ethtool support for fec and link configuration [not found] <1612098665-187767-1-git-send-email-hkelam@marvell.com> 2021-01-31 13:11 ` [Patch v3 net-next 5/7] octeontx2-af: advertised link modes support on cgx Hariprasad Kelam 2021-01-31 13:11 ` [Patch v3 net-next 6/7] octeontx2-pf: ethtool physical link status Hariprasad Kelam @ 2021-02-01 0:54 ` Willem de Bruijn [not found] ` <1612098665-187767-8-git-send-email-hkelam@marvell.com> 3 siblings, 0 replies; 12+ messages in thread From: Willem de Bruijn @ 2021-02-01 0:54 UTC (permalink / raw) To: Hariprasad Kelam Cc: Network Development, LKML, Jakub Kicinski, David Miller, Andrew Lunn, Sunil Kovvuri Goutham, Linu Cherian, Geethasowjanya Akula, Jerin Jacob, Subbaraya Sundeep Bhatta On Sun, Jan 31, 2021 at 8:11 AM Hariprasad Kelam <hkelam@marvell.com> wrote: > > This series of patches add support for forward error correction(fec) and > physical link configuration. Patches 1&2 adds necessary mbox handlers for fec > mode configuration request and to fetch stats. Patch 3 registers driver > callbacks for fec mode configuration and display. Patch 4&5 adds support of mbox > handlers for configuring link parameters like speed/duplex and autoneg etc. > Patche 6&7 registers driver callbacks for physical link configuration. > > Change-log: > v2: > - Fixed review comments > - Corrected indentation issues > - Return -ENOMEM incase of mbox allocation failure > - added validation for input fecparams bitmask values > - added more comments > > V3: > - Removed inline functions > - Make use of ethtool helpers APIs to display supported > advertised modes > - corrected indentation issues > - code changes such that return early in case of failure > to aid branch prediction This addresses my comments to the previous patch series, thanks. It seems that patchwork only picked up only patch 6/7 unfortunately: https://patchwork.kernel.org/project/netdevbpf/list/?series=424969 > > Christina Jacob (6): > octeontx2-af: forward error correction configuration > octeontx2-pf: ethtool fec mode support > octeontx2-af: Physical link configuration support > octeontx2-af: advertised link modes support on cgx > octeontx2-pf: ethtool physical link status > octeontx2-pf: ethtool physical link configuration > > Felix Manlunas (1): > octeontx2-af: Add new CGX_CMD to get PHY FEC statistics > > drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 258 ++++++++++++- > drivers/net/ethernet/marvell/octeontx2/af/cgx.h | 10 + > .../net/ethernet/marvell/octeontx2/af/cgx_fw_if.h | 70 +++- > drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 87 ++++- > drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 4 + > .../net/ethernet/marvell/octeontx2/af/rvu_cgx.c | 80 +++++ > .../ethernet/marvell/octeontx2/nic/otx2_common.c | 20 ++ > .../ethernet/marvell/octeontx2/nic/otx2_common.h | 6 + > .../ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 399 ++++++++++++++++++++- > .../net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 3 + > 10 files changed, 930 insertions(+), 7 deletions(-) > > -- > 2.7.4 ^ permalink raw reply [flat|nested] 12+ messages in thread
[parent not found: <1612098665-187767-8-git-send-email-hkelam@marvell.com>]
* Re: [Patch v3 net-next 7/7] octeontx2-pf: ethtool physical link configuration [not found] ` <1612098665-187767-8-git-send-email-hkelam@marvell.com> @ 2021-02-03 1:29 ` Jakub Kicinski 0 siblings, 0 replies; 12+ messages in thread From: Jakub Kicinski @ 2021-02-03 1:29 UTC (permalink / raw) To: Hariprasad Kelam Cc: netdev, linux-kernel, davem, willemdebruijn.kernel, andrew, sgoutham, lcherian, gakula, jerinj, sbhatta On Sun, 31 Jan 2021 18:41:05 +0530 Hariprasad Kelam wrote: > From: Christina Jacob <cjacob@marvell.com> > > Register set_link_ksetting callback with driver such that > link configurations parameters like advertised mode,speed, duplex > and autoneg can be configured. > > below command > ethtool -s eth0 advertise 0x1 speed 10 duplex full autoneg on > > Signed-off-by: Christina Jacob <cjacob@marvell.com> > Signed-off-by: Sunil Goutham <sgoutham@marvell.com> > Signed-off-by: Hariprasad Kelam <hkelam@marvell.com> > --- > .../ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 67 ++++++++++++++++++++++ > 1 file changed, 67 insertions(+) > > diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c > index d637815..74a62de 100644 > --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c > +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c > @@ -1170,6 +1170,72 @@ static int otx2_get_link_ksettings(struct net_device *netdev, > return 0; > } > > +static void otx2_get_advertised_mode(const struct ethtool_link_ksettings *cmd, > + u64 *mode) > +{ > + u32 bit_pos; > + > + /* Firmware does not support requesting multiple advertised modes > + * return first set bit > + */ > + bit_pos = find_first_bit(cmd->link_modes.advertising, > + __ETHTOOL_LINK_MODE_MASK_NBITS); > + if (bit_pos != __ETHTOOL_LINK_MODE_MASK_NBITS) > + *mode = bit_pos; > +} > + > +static int otx2_set_link_ksettings(struct net_device *netdev, > + const struct ethtool_link_ksettings *cmd) > +{ > + struct otx2_nic *pf = netdev_priv(netdev); > + struct ethtool_link_ksettings req_ks; > + struct ethtool_link_ksettings cur_ks; > + struct cgx_set_link_mode_req *req; > + struct mbox *mbox = &pf->mbox; > + int err = 0; > + > + /* save requested link settings */ > + memcpy(&req_ks, cmd, sizeof(struct ethtool_link_ksettings)); Why do you make this copy? The comment above does not help at all. > + memset(&cur_ks, 0, sizeof(struct ethtool_link_ksettings)); > + > + if (!ethtool_validate_speed(cmd->base.speed) || > + !ethtool_validate_duplex(cmd->base.duplex)) > + return -EINVAL; > + > + if (cmd->base.autoneg != AUTONEG_ENABLE && > + cmd->base.autoneg != AUTONEG_DISABLE) > + return -EINVAL; > + > + otx2_get_link_ksettings(netdev, &cur_ks); > + > + /* Check requested modes against supported modes by hardware */ > + if (!bitmap_subset(req_ks.link_modes.advertising, > + cur_ks.link_modes.supported, > + __ETHTOOL_LINK_MODE_MASK_NBITS)) > + return -EINVAL; > + > + mutex_lock(&mbox->lock); > + req = otx2_mbox_alloc_msg_cgx_set_link_mode(&pf->mbox); > + if (!req) { > + err = -ENOMEM; > + goto end; > + } > + > + req->args.speed = req_ks.base.speed; > + /* firmware expects 1 for half duplex and 0 for full duplex > + * hence inverting > + */ > + req->args.duplex = req_ks.base.duplex ^ 0x1; > + req->args.an = req_ks.base.autoneg; > + otx2_get_advertised_mode(&req_ks, &req->args.mode); But that only returns the first bit set. What does the device actually do? What if the user cleared a middle bit? > + err = otx2_sync_mbox_msg(&pf->mbox); > +end: > + mutex_unlock(&mbox->lock); > + return err; > +} > + > static const struct ethtool_ops otx2_ethtool_ops = { > .supported_coalesce_params = ETHTOOL_COALESCE_USECS | > ETHTOOL_COALESCE_MAX_FRAMES, > @@ -1200,6 +1266,7 @@ static const struct ethtool_ops otx2_ethtool_ops = { > .get_fecparam = otx2_get_fecparam, > .set_fecparam = otx2_set_fecparam, > .get_link_ksettings = otx2_get_link_ksettings, > + .set_link_ksettings = otx2_set_link_ksettings, > }; > > void otx2_set_ethtool_ops(struct net_device *netdev) ^ permalink raw reply [flat|nested] 12+ messages in thread
* [Patch v3 net-next 0/7] ethtool support for fec and link configuration @ 2021-02-01 5:24 Hariprasad Kelam 2021-02-01 5:24 ` [Patch v3 net-next 7/7] octeontx2-pf: ethtool physical " Hariprasad Kelam 0 siblings, 1 reply; 12+ messages in thread From: Hariprasad Kelam @ 2021-02-01 5:24 UTC (permalink / raw) To: netdev, linux-kernel Cc: kuba, davem, willemdebruijn.kernel, andrew, sgoutham, lcherian, gakula, jerinj, sbhatta, hkelam This series of patches add support for forward error correction(fec) and physical link configuration. Patches 1&2 adds necessary mbox handlers for fec mode configuration request and to fetch stats. Patch 3 registers driver callbacks for fec mode configuration and display. Patch 4&5 adds support of mbox handlers for configuring link parameters like speed/duplex and autoneg etc. Patche 6&7 registers driver callbacks for physical link configuration. Change-log: v2: - Fixed review comments - Corrected indentation issues - Return -ENOMEM incase of mbox allocation failure - added validation for input fecparams bitmask values - added more comments V3: - Removed inline functions - Make use of ethtool helpers APIs to display supported advertised modes - corrected indentation issues - code changes such that return early in case of failure to aid branch prediction Christina Jacob (6): octeontx2-af: forward error correction configuration octeontx2-pf: ethtool fec mode support octeontx2-af: Physical link configuration support octeontx2-af: advertised link modes support on cgx octeontx2-pf: ethtool physical link status octeontx2-pf: ethtool physical link configuration Felix Manlunas (1): octeontx2-af: Add new CGX_CMD to get PHY FEC statistics drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 258 ++++++++++++- drivers/net/ethernet/marvell/octeontx2/af/cgx.h | 10 + .../net/ethernet/marvell/octeontx2/af/cgx_fw_if.h | 70 +++- drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 87 ++++- drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 4 + .../net/ethernet/marvell/octeontx2/af/rvu_cgx.c | 80 +++++ .../ethernet/marvell/octeontx2/nic/otx2_common.c | 20 ++ .../ethernet/marvell/octeontx2/nic/otx2_common.h | 6 + .../ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 399 ++++++++++++++++++++- .../net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 3 + 10 files changed, 930 insertions(+), 7 deletions(-) -- 2.7.4 ^ permalink raw reply [flat|nested] 12+ messages in thread
* [Patch v3 net-next 7/7] octeontx2-pf: ethtool physical link configuration 2021-02-01 5:24 [Patch v3 net-next 0/7] ethtool support for fec and " Hariprasad Kelam @ 2021-02-01 5:24 ` Hariprasad Kelam 2021-02-03 0:48 ` Jesse Brandeburg 0 siblings, 1 reply; 12+ messages in thread From: Hariprasad Kelam @ 2021-02-01 5:24 UTC (permalink / raw) To: netdev, linux-kernel Cc: kuba, davem, willemdebruijn.kernel, andrew, sgoutham, lcherian, gakula, jerinj, sbhatta, hkelam From: Christina Jacob <cjacob@marvell.com> Register set_link_ksetting callback with driver such that link configurations parameters like advertised mode,speed, duplex and autoneg can be configured. below command ethtool -s eth0 advertise 0x1 speed 10 duplex full autoneg on Signed-off-by: Christina Jacob <cjacob@marvell.com> Signed-off-by: Sunil Goutham <sgoutham@marvell.com> Signed-off-by: Hariprasad Kelam <hkelam@marvell.com> --- .../ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 67 ++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c index d637815..74a62de 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c @@ -1170,6 +1170,72 @@ static int otx2_get_link_ksettings(struct net_device *netdev, return 0; } +static void otx2_get_advertised_mode(const struct ethtool_link_ksettings *cmd, + u64 *mode) +{ + u32 bit_pos; + + /* Firmware does not support requesting multiple advertised modes + * return first set bit + */ + bit_pos = find_first_bit(cmd->link_modes.advertising, + __ETHTOOL_LINK_MODE_MASK_NBITS); + if (bit_pos != __ETHTOOL_LINK_MODE_MASK_NBITS) + *mode = bit_pos; +} + +static int otx2_set_link_ksettings(struct net_device *netdev, + const struct ethtool_link_ksettings *cmd) +{ + struct otx2_nic *pf = netdev_priv(netdev); + struct ethtool_link_ksettings req_ks; + struct ethtool_link_ksettings cur_ks; + struct cgx_set_link_mode_req *req; + struct mbox *mbox = &pf->mbox; + int err = 0; + + /* save requested link settings */ + memcpy(&req_ks, cmd, sizeof(struct ethtool_link_ksettings)); + + memset(&cur_ks, 0, sizeof(struct ethtool_link_ksettings)); + + if (!ethtool_validate_speed(cmd->base.speed) || + !ethtool_validate_duplex(cmd->base.duplex)) + return -EINVAL; + + if (cmd->base.autoneg != AUTONEG_ENABLE && + cmd->base.autoneg != AUTONEG_DISABLE) + return -EINVAL; + + otx2_get_link_ksettings(netdev, &cur_ks); + + /* Check requested modes against supported modes by hardware */ + if (!bitmap_subset(req_ks.link_modes.advertising, + cur_ks.link_modes.supported, + __ETHTOOL_LINK_MODE_MASK_NBITS)) + return -EINVAL; + + mutex_lock(&mbox->lock); + req = otx2_mbox_alloc_msg_cgx_set_link_mode(&pf->mbox); + if (!req) { + err = -ENOMEM; + goto end; + } + + req->args.speed = req_ks.base.speed; + /* firmware expects 1 for half duplex and 0 for full duplex + * hence inverting + */ + req->args.duplex = req_ks.base.duplex ^ 0x1; + req->args.an = req_ks.base.autoneg; + otx2_get_advertised_mode(&req_ks, &req->args.mode); + + err = otx2_sync_mbox_msg(&pf->mbox); +end: + mutex_unlock(&mbox->lock); + return err; +} + static const struct ethtool_ops otx2_ethtool_ops = { .supported_coalesce_params = ETHTOOL_COALESCE_USECS | ETHTOOL_COALESCE_MAX_FRAMES, @@ -1200,6 +1266,7 @@ static const struct ethtool_ops otx2_ethtool_ops = { .get_fecparam = otx2_get_fecparam, .set_fecparam = otx2_set_fecparam, .get_link_ksettings = otx2_get_link_ksettings, + .set_link_ksettings = otx2_set_link_ksettings, }; void otx2_set_ethtool_ops(struct net_device *netdev) -- 2.7.4 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [Patch v3 net-next 7/7] octeontx2-pf: ethtool physical link configuration 2021-02-01 5:24 ` [Patch v3 net-next 7/7] octeontx2-pf: ethtool physical " Hariprasad Kelam @ 2021-02-03 0:48 ` Jesse Brandeburg 0 siblings, 0 replies; 12+ messages in thread From: Jesse Brandeburg @ 2021-02-03 0:48 UTC (permalink / raw) To: Hariprasad Kelam Cc: netdev, linux-kernel, kuba, davem, willemdebruijn.kernel, andrew, sgoutham, lcherian, gakula, jerinj, sbhatta Hariprasad Kelam wrote: > From: Christina Jacob <cjacob@marvell.com> > > Register set_link_ksetting callback with driver such that > link configurations parameters like advertised mode,speed, duplex > and autoneg can be configured. > > below command > ethtool -s eth0 advertise 0x1 speed 10 duplex full autoneg on > > Signed-off-by: Christina Jacob <cjacob@marvell.com> > Signed-off-by: Sunil Goutham <sgoutham@marvell.com> > Signed-off-by: Hariprasad Kelam <hkelam@marvell.com> Reviewed-by: Jesse Brandeburg <jesse.brandeburg@intel.com> ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Patch v3 net-next 7/7] octeontx2-pf: ethtool physical link configuration @ 2021-02-04 17:37 Hariprasad Kelam 2021-02-04 18:50 ` Jakub Kicinski 0 siblings, 1 reply; 12+ messages in thread From: Hariprasad Kelam @ 2021-02-04 17:37 UTC (permalink / raw) To: Jakub Kicinski Cc: netdev, linux-kernel, davem, willemdebruijn.kernel, andrew, Sunil Kovvuri Goutham, Linu Cherian, Geethasowjanya Akula, Jerin Jacob Kollanukkaran, Subbaraya Sundeep Bhatta Hi Jakub, > -----Original Message----- > From: Jakub Kicinski <kuba@kernel.org> > Sent: Wednesday, February 3, 2021 6:59 AM > To: Hariprasad Kelam <hkelam@marvell.com> > Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org; > davem@davemloft.net; willemdebruijn.kernel@gmail.com; > andrew@lunn.ch; Sunil Kovvuri Goutham <sgoutham@marvell.com>; Linu > Cherian <lcherian@marvell.com>; Geethasowjanya Akula > <gakula@marvell.com>; Jerin Jacob Kollanukkaran <jerinj@marvell.com>; > Subbaraya Sundeep Bhatta <sbhatta@marvell.com> > Subject: [EXT] Re: [Patch v3 net-next 7/7] octeontx2-pf: ethtool physical link > configuration > > On Sun, 31 Jan 2021 18:41:05 +0530 Hariprasad Kelam wrote: > > From: Christina Jacob <cjacob@marvell.com> > > > > Register set_link_ksetting callback with driver such that link > > configurations parameters like advertised mode,speed, duplex and > > autoneg can be configured. > > > > below command > > ethtool -s eth0 advertise 0x1 speed 10 duplex full autoneg on > > > > Signed-off-by: Christina Jacob <cjacob@marvell.com> > > Signed-off-by: Sunil Goutham <sgoutham@marvell.com> > > Signed-off-by: Hariprasad Kelam <hkelam@marvell.com> > > --- > > .../ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 67 > > ++++++++++++++++++++++ > > 1 file changed, 67 insertions(+) > > > > diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c > > b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c > > index d637815..74a62de 100644 > > --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c > > +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c > > @@ -1170,6 +1170,72 @@ static int otx2_get_link_ksettings(struct > net_device *netdev, > > return 0; > > } > > > > +static void otx2_get_advertised_mode(const struct ethtool_link_ksettings > *cmd, > > + u64 *mode) > > +{ > > + u32 bit_pos; > > + > > + /* Firmware does not support requesting multiple advertised modes > > + * return first set bit > > + */ > > + bit_pos = find_first_bit(cmd->link_modes.advertising, > > + __ETHTOOL_LINK_MODE_MASK_NBITS); > > + if (bit_pos != __ETHTOOL_LINK_MODE_MASK_NBITS) > > + *mode = bit_pos; > > +} > > + > > +static int otx2_set_link_ksettings(struct net_device *netdev, > > + const struct ethtool_link_ksettings *cmd) { > > + struct otx2_nic *pf = netdev_priv(netdev); > > + struct ethtool_link_ksettings req_ks; > > + struct ethtool_link_ksettings cur_ks; > > + struct cgx_set_link_mode_req *req; > > + struct mbox *mbox = &pf->mbox; > > + int err = 0; > > + > > + /* save requested link settings */ > > + memcpy(&req_ks, cmd, sizeof(struct ethtool_link_ksettings)); > > Why do you make this copy? The comment above does not help at all. > Agreed copy is not necessary . Added this copy for comparing advertised modes with supported modes. Will fix this in next version. > > + memset(&cur_ks, 0, sizeof(struct ethtool_link_ksettings)); > > + > > + if (!ethtool_validate_speed(cmd->base.speed) || > > + !ethtool_validate_duplex(cmd->base.duplex)) > > + return -EINVAL; > > + > > + if (cmd->base.autoneg != AUTONEG_ENABLE && > > + cmd->base.autoneg != AUTONEG_DISABLE) > > + return -EINVAL; > > + > > + otx2_get_link_ksettings(netdev, &cur_ks); > > + > > + /* Check requested modes against supported modes by hardware */ > > + if (!bitmap_subset(req_ks.link_modes.advertising, > > + cur_ks.link_modes.supported, > > + __ETHTOOL_LINK_MODE_MASK_NBITS)) > > + return -EINVAL; > > + > > + mutex_lock(&mbox->lock); > > + req = otx2_mbox_alloc_msg_cgx_set_link_mode(&pf->mbox); > > + if (!req) { > > + err = -ENOMEM; > > + goto end; > > + } > > + > > + req->args.speed = req_ks.base.speed; > > + /* firmware expects 1 for half duplex and 0 for full duplex > > + * hence inverting > > + */ > > + req->args.duplex = req_ks.base.duplex ^ 0x1; > > + req->args.an = req_ks.base.autoneg; > > + otx2_get_advertised_mode(&req_ks, &req->args.mode); > > But that only returns the first bit set. What does the device actually do? What > if the user cleared a middle bit? > This is initial patch series to support advertised modes. Current firmware design is such that It can handle only one advertised mode. Due to this limitation we are always checking The first set bit in advertised modes and passing it to firmware. Will add multi advertised mode support in near future. Thanks, Hariprasad k > > + err = otx2_sync_mbox_msg(&pf->mbox); > > +end: > > + mutex_unlock(&mbox->lock); > > + return err; > > +} > > + > > static const struct ethtool_ops otx2_ethtool_ops = { > > .supported_coalesce_params = ETHTOOL_COALESCE_USECS | > > ETHTOOL_COALESCE_MAX_FRAMES, @@ > -1200,6 +1266,7 @@ static > > const struct ethtool_ops otx2_ethtool_ops = { > > .get_fecparam = otx2_get_fecparam, > > .set_fecparam = otx2_set_fecparam, > > .get_link_ksettings = otx2_get_link_ksettings, > > + .set_link_ksettings = otx2_set_link_ksettings, > > }; > > > > void otx2_set_ethtool_ops(struct net_device *netdev) ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Patch v3 net-next 7/7] octeontx2-pf: ethtool physical link configuration 2021-02-04 17:37 Hariprasad Kelam @ 2021-02-04 18:50 ` Jakub Kicinski 0 siblings, 0 replies; 12+ messages in thread From: Jakub Kicinski @ 2021-02-04 18:50 UTC (permalink / raw) To: Hariprasad Kelam Cc: netdev, linux-kernel, davem, willemdebruijn.kernel, andrew, Sunil Kovvuri Goutham, Linu Cherian, Geethasowjanya Akula, Jerin Jacob Kollanukkaran, Subbaraya Sundeep Bhatta On Thu, 4 Feb 2021 17:37:41 +0000 Hariprasad Kelam wrote: > > > + req->args.speed = req_ks.base.speed; > > > + /* firmware expects 1 for half duplex and 0 for full duplex > > > + * hence inverting > > > + */ > > > + req->args.duplex = req_ks.base.duplex ^ 0x1; > > > + req->args.an = req_ks.base.autoneg; > > > + otx2_get_advertised_mode(&req_ks, &req->args.mode); > > > > But that only returns the first bit set. What does the device actually do? What > > if the user cleared a middle bit? > > > This is initial patch series to support advertised modes. Current firmware design is such that > It can handle only one advertised mode. Due to this limitation we are always checking > The first set bit in advertised modes and passing it to firmware. > Will add multi advertised mode support in near future. Looking at patch 6 it seems like the get side already supports multiple modes, although the example output only lists supported no advertised. Is the device actually doing IEEE autoneg or just configures the speed, lanes etc. according to the link mode selected? ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Patch v3 net-next 7/7] octeontx2-pf: ethtool physical link configuration
@ 2021-02-05 14:15 Hariprasad Kelam
2021-02-05 19:25 ` Jakub Kicinski
0 siblings, 1 reply; 12+ messages in thread
From: Hariprasad Kelam @ 2021-02-05 14:15 UTC (permalink / raw)
To: Jakub Kicinski
Cc: netdev, linux-kernel, davem, willemdebruijn.kernel, andrew,
Sunil Kovvuri Goutham, Linu Cherian, Geethasowjanya Akula,
Jerin Jacob Kollanukkaran, Subbaraya Sundeep Bhatta
Hi Jakub,
> -----Original Message-----
> From: Jakub Kicinski <kuba@kernel.org>
> Sent: Friday, February 5, 2021 12:21 AM
> To: Hariprasad Kelam <hkelam@marvell.com>
> Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org;
> davem@davemloft.net; willemdebruijn.kernel@gmail.com;
> andrew@lunn.ch; Sunil Kovvuri Goutham <sgoutham@marvell.com>; Linu
> Cherian <lcherian@marvell.com>; Geethasowjanya Akula
> <gakula@marvell.com>; Jerin Jacob Kollanukkaran <jerinj@marvell.com>;
> Subbaraya Sundeep Bhatta <sbhatta@marvell.com>
> Subject: [EXT] Re: [Patch v3 net-next 7/7] octeontx2-pf: ethtool physical link
> configuration
>
> On Thu, 4 Feb 2021 17:37:41 +0000 Hariprasad Kelam wrote:
> > > > + req->args.speed = req_ks.base.speed;
> > > > + /* firmware expects 1 for half duplex and 0 for full duplex
> > > > + * hence inverting
> > > > + */
> > > > + req->args.duplex = req_ks.base.duplex ^ 0x1;
> > > > + req->args.an = req_ks.base.autoneg;
> > > > + otx2_get_advertised_mode(&req_ks, &req->args.mode);
> > >
> > > But that only returns the first bit set. What does the device
> > > actually do? What if the user cleared a middle bit?
> > >
> > This is initial patch series to support advertised modes. Current
> > firmware design is such that It can handle only one advertised mode.
> > Due to this limitation we are always checking The first set bit in advertised
> modes and passing it to firmware.
> > Will add multi advertised mode support in near future.
>
> Looking at patch 6 it seems like the get side already supports multiple modes,
> although the example output only lists supported no advertised.
>
> Is the device actually doing IEEE autoneg or just configures the speed, lanes
> etc. according to the link mode selected?
Device supports IEEE autoneg mode. Agreed get_link_ksetting returns multiple modes .
But set side firmware code designed in such way that it handles single mode. Upon
Successful configuration firmware updates advertised modes to shared memory
such that kernel will read and updates to ethtool.
Thanks,
Hariprasad k
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Patch v3 net-next 7/7] octeontx2-pf: ethtool physical link configuration 2021-02-05 14:15 Hariprasad Kelam @ 2021-02-05 19:25 ` Jakub Kicinski 0 siblings, 0 replies; 12+ messages in thread From: Jakub Kicinski @ 2021-02-05 19:25 UTC (permalink / raw) To: Hariprasad Kelam Cc: netdev, linux-kernel, davem, willemdebruijn.kernel, andrew, Sunil Kovvuri Goutham, Linu Cherian, Geethasowjanya Akula, Jerin Jacob Kollanukkaran, Subbaraya Sundeep Bhatta On Fri, 5 Feb 2021 14:15:01 +0000 Hariprasad Kelam wrote: > > > Will add multi advertised mode support in near future. > > > > Looking at patch 6 it seems like the get side already supports multiple modes, > > although the example output only lists supported no advertised. > > > > Is the device actually doing IEEE autoneg or just configures the speed, lanes > > etc. according to the link mode selected? > > Device supports IEEE autoneg mode. Agreed get_link_ksetting returns multiple modes . > But set side firmware code designed in such way that it handles single mode. Upon > Successful configuration firmware updates advertised modes to shared memory > such that kernel will read and updates to ethtool. It needs to be symmetric, get needs to reflect what set specified. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Patch v3 net-next 7/7] octeontx2-pf: ethtool physical link configuration
@ 2021-02-07 15:22 Hariprasad Kelam
0 siblings, 0 replies; 12+ messages in thread
From: Hariprasad Kelam @ 2021-02-07 15:22 UTC (permalink / raw)
To: Jakub Kicinski
Cc: netdev, linux-kernel, davem, willemdebruijn.kernel, andrew,
Sunil Kovvuri Goutham, Linu Cherian, Geethasowjanya Akula,
Jerin Jacob Kollanukkaran, Subbaraya Sundeep Bhatta
Hi Jakub,
> -----Original Message-----
> From: Jakub Kicinski <kuba@kernel.org>
> Sent: Saturday, February 6, 2021 12:56 AM
> To: Hariprasad Kelam <hkelam@marvell.com>
> Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org;
> davem@davemloft.net; willemdebruijn.kernel@gmail.com;
> andrew@lunn.ch; Sunil Kovvuri Goutham <sgoutham@marvell.com>; Linu
> Cherian <lcherian@marvell.com>; Geethasowjanya Akula
> <gakula@marvell.com>; Jerin Jacob Kollanukkaran <jerinj@marvell.com>;
> Subbaraya Sundeep Bhatta <sbhatta@marvell.com>
> Subject: [EXT] Re: [Patch v3 net-next 7/7] octeontx2-pf: ethtool physical link
> configuration
>
> On Fri, 5 Feb 2021 14:15:01 +0000 Hariprasad Kelam wrote:
> > > > Will add multi advertised mode support in near future.
> > >
> > > Looking at patch 6 it seems like the get side already supports
> > > multiple modes, although the example output only lists supported no
> advertised.
> > >
> > > Is the device actually doing IEEE autoneg or just configures the
> > > speed, lanes etc. according to the link mode selected?
> >
> > Device supports IEEE autoneg mode. Agreed get_link_ksetting returns
> multiple modes .
> > But set side firmware code designed in such way that it handles
> > single mode. Upon Successful configuration firmware updates advertised
> > modes to shared memory such that kernel will read and updates to
> ethtool.
>
> It needs to be symmetric, get needs to reflect what set specified.
Agreed. Even though set supports single mode still it is displayed with get link settings.
Thanks,
Hariprasad k
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2021-02-07 15:28 UTC | newest] Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <1612098665-187767-1-git-send-email-hkelam@marvell.com> 2021-01-31 13:11 ` [Patch v3 net-next 5/7] octeontx2-af: advertised link modes support on cgx Hariprasad Kelam 2021-01-31 13:11 ` [Patch v3 net-next 6/7] octeontx2-pf: ethtool physical link status Hariprasad Kelam 2021-02-03 1:23 ` Jakub Kicinski 2021-02-01 0:54 ` [Patch v3 net-next 0/7] ethtool support for fec and link configuration Willem de Bruijn [not found] ` <1612098665-187767-8-git-send-email-hkelam@marvell.com> 2021-02-03 1:29 ` [Patch v3 net-next 7/7] octeontx2-pf: ethtool physical " Jakub Kicinski 2021-02-01 5:24 [Patch v3 net-next 0/7] ethtool support for fec and " Hariprasad Kelam 2021-02-01 5:24 ` [Patch v3 net-next 7/7] octeontx2-pf: ethtool physical " Hariprasad Kelam 2021-02-03 0:48 ` Jesse Brandeburg 2021-02-04 17:37 Hariprasad Kelam 2021-02-04 18:50 ` Jakub Kicinski 2021-02-05 14:15 Hariprasad Kelam 2021-02-05 19:25 ` Jakub Kicinski 2021-02-07 15:22 Hariprasad Kelam
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.