net: hns3: enhance capabilities for fibre port
Subsystems (4)
v2 cover net: hns3: enhance capabilities for fibre port
From: Jian Shen <[email protected]>
This patchset enhances more capabilities for fibre port, include multipe media type identification, autoneg, change port speed and FEC encoding.
Jian Shen (3):
net: hns3: add support for multiple media type
net: hns3: add autoneg and change speed support for fibre port
net: hns3: add support for FEC encoding control
Change log:V1->V2: fixes comments from Andrew Lunn.
drivers/net/ethernet/hisilicon/hns3/hnae3.h | 34 +- drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 180 ++++++++- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h | 30 +- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 410 ++++++++++++++++++--- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 16 +- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c | 7 +- .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 15 +- .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h | 1 + 8 files changed, 620 insertions(+), 73 deletions(-)
Signature · 1 line
1.9.1
PATCH v2 1/3 net: hns3: add support for multiple media type
From: Jian Shen <[email protected]>
Previously, we can only identify copper and fiber type, the supported link modes of port information are always showing SR type. This patch adds support for multiple media types, include SR, LR CR, KR. Driver needs to query the media type from firmware periodicly, and updates the port information.
The new port information looks like this:
Settings for eth0:
Supported ports: [ FIBRE ]
Supported link modes: 25000baseCR/Full
25000baseSR/Full 1000baseX/Full 10000baseCR/Full 10000baseSR/Full 10000baseLR/Full
Supported pause frame use: Symmetric Supports auto-negotiation: No Supported FEC modes: None BaseR Advertised link modes: Not reported Advertised pause frame use: No Advertised auto-negotiation: No Advertised FEC modes: Not reported
Speed: 10000Mb/s
Duplex: Full
Port: FIBRE
PHYAD: 0
Transceiver: internal
Auto-negotiation: off
Current message level: 0x00000036 (54)
probe link ifdown ifup
Link detected: yes
In order to be compatible with old firmware which only support sfp speed, we remained using the same query command, and kept the former logic.
---
Change log:V1->V2: fixes comments from Andrew Lunn.
--- drivers/net/ethernet/hisilicon/hns3/hnae3.h | 18 +- drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 13 +- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h | 14 +- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 230 +++++++++++++++++---- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 11 +- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c | 7 +- .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 15 +- .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h | 1 + 8 files changed, 246 insertions(+), 63 deletions(-)
drivers/net/ethernet/hisilicon/hns3/hnae3.h +14 -4
@@ -120,6 +120,18 @@ enum hnae3_media_type { HNAE3_MEDIA_TYPE_NONE, }; +/* must be consistent with definition in firmware */ +enum hnae3_module_type { +HNAE3_MODULE_TYPE_UNKNOWN =0x00 , +HNAE3_MODULE_TYPE_FIBRE_LR =0x01 , +HNAE3_MODULE_TYPE_FIBRE_SR =0x02 , +HNAE3_MODULE_TYPE_AOC =0x03 , +HNAE3_MODULE_TYPE_CR =0x04 , +HNAE3_MODULE_TYPE_KR =0x05 , +HNAE3_MODULE_TYPE_TP =0x06 , + +}; +enum hnae3_reset_notify_type {HNAE3_UP_CLIENT ,HNAE3_DOWN_CLIENT ,
@@ -230,8 +242,6 @@ struct hnae3_ae_dev {* non-ok * get_ksettings_an_result() * Get negotiation status,speed and duplex -* update_speed_duplex_h() -* Update hardware speed and duplex * get_media_type() * Get media type of MAC * adjust_link()
@@ -340,11 +350,11 @@ struct hnae3_ae_ops {void (*get_ksettings_an_result)(struct hnae3_handle *handle,u8 *auto_neg,u32 *speed,u8 *duplex); -int (*update_speed_duplex_h)(struct hnae3_handle *handle);int (*cfg_mac_speed_dup_h)(struct hnae3_handle *handle,int speed,u8 duplex); -void (*get_media_type)(struct hnae3_handle *handle,u8 *media_type); +void (*get_media_type)(struct hnae3_handle *handle,u8 *media_type, +u8 *module_type);void (*adjust_link)(struct hnae3_handle *handle,int speed,int duplex);int (*set_loopback)(struct hnae3_handle *handle,enum hnae3_loop loop_mode,bool en);
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +11 -2
@@ -604,6 +604,7 @@ static int hns3_get_link_ksettings(struct net_device *netdev, {struct hnae3_handle *h =hns3_get_handle (netdev);const struct hnae3_ae_ops *ops; +u8 module_type;u8 media_type;u8 link_stat;
@@ -612,7 +613,7 @@ static int hns3_get_link_ksettings(struct net_device *netdev, ops = h->ae_algo->ops;if (ops->get_media_type) - ops->get_media_type (h, &media_type); + ops->get_media_type (h, &media_type, &module_type);else return -EOPNOTSUPP ;
@@ -622,7 +623,15 @@ static int hns3_get_link_ksettings(struct net_device *netdev,hns3_get_ksettings (h, cmd);break ;case HNAE3_MEDIA_TYPE_FIBER : - cmd->base.port =PORT_FIBRE ; +if (module_type ==HNAE3_MODULE_TYPE_CR ) + cmd->base.port =PORT_DA ; +else + cmd->base.port =PORT_FIBRE ; + +hns3_get_ksettings (h, cmd); +break ; +case HNAE3_MEDIA_TYPE_BACKPLANE : + cmd->base.port =PORT_NONE ;hns3_get_ksettings (h, cmd);break ;case HNAE3_MEDIA_TYPE_COPPER :
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h +10 -4
@@ -244,7 +244,7 @@ enum hclge_opcode_type {HCLGE_OPC_QUERY_NCL_CONFIG =0x7011 ,/* SFP command */ -HCLGE_OPC_SFP_GET_SPEED =0x7104 , +HCLGE_OPC_GET_SFP_INFO =0x7104 ,/* Error INT commands */ HCLGE_MAC_COMMON_INT_EN = 0x030E,
@@ -599,9 +599,15 @@ struct hclge_config_auto_neg_cmd {u8 rsv[20 ]; }; -struct hclge_sfp_speed_cmd { -__le32 sfp_speed; -u32 rsv[5 ]; +struct hclge_sfp_info_cmd { +__le32 speed; +u8 query_type;/* 0: sfp speed, 1: active speed */ +u8 active_fec; +u8 autoneg;/* autoneg state */ +u8 autoneg_ability;/* whether support autoneg */ +__le32 speed_ability;/* speed ability for current media */ +__le32 module_type; +u8 rsv[8 ]; };#define HCLGE_MAC_UPLINK_PORT 0x100
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +186 -44
315 lines not on this page · raw message
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +10 -1
@@ -189,6 +189,8 @@ enum HLCGE_PORT_TYPE {#define HCLGE_SUPPORT_25G_BIT BIT(2)#define HCLGE_SUPPORT_50G_BIT BIT(3)#define HCLGE_SUPPORT_100G_BIT BIT(4) +/* to be compatible with exsit board */ +#define HCLGE_SUPPORT_40G_BIT BIT(5)#define HCLGE_SUPPORT_100M_BIT BIT(6)#define HCLGE_SUPPORT_10M_BIT BIT(7)#define HCLGE_SUPPORT_GE \
@@ -236,14 +238,21 @@ enum HCLGE_MAC_DUPLEX {HCLGE_MAC_FULL }; +#define QUERY_SFP_SPEED 0 +#define QUERY_ACTIVE_SPEED 1 +struct hclge_mac {u8 phy_addr;u8 flag; -u8 media_type; +u8 media_type;/* port media type, e.g. fibre/copper/backplane */ u8 mac_addr[ETH_ALEN ];u8 autoneg;u8 duplex; +u8 support_autoneg; +u8 speed_type;/* 0: sfp speed, 1: active speed */ u32 speed; +u32 speed_ability;/* speed ability supported by current media */ +u32 module_type;/* sub media type, e.g. kr/cr/sr/lr */ int link;/* store the link status of mac & phy (if phy exit)*/ struct phy_device *phydev;struct mii_bus *mdio_bus;
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c +4 -3
@@ -412,10 +412,11 @@ static int hclge_get_vf_media_type(struct hclge_vport *vport, struct hclge_mbx_vf_to_pf_cmd *mbx_req) {struct hclge_dev *hdev = vport->back; -u8 resp_data; +u8 resp_data[2 ]; - resp_data = hdev->hw.mac.media_type; -return hclge_gen_resp_to_vf (vport, mbx_req,0 , &resp_data, + resp_data[0 ] = hdev->hw.mac.media_type; + resp_data[1 ] = hdev->hw.mac.module_type; +return hclge_gen_resp_to_vf (vport, mbx_req,0 , resp_data,sizeof (resp_data)); }
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +10 -5
@@ -330,11 +330,11 @@ static u16 hclgevf_get_qid_global(struct hnae3_handle *handle, u16 queue_id)static int hclgevf_get_pf_media_type (struct hclgevf_dev *hdev) { -u8 resp_msg; +u8 resp_msg[2 ];int ret; ret =hclgevf_send_mbx_msg (hdev,HCLGE_MBX_GET_MEDIA_TYPE ,0 ,NULL ,0 , - true, &resp_msg,sizeof (resp_msg)); + true, resp_msg,sizeof (resp_msg));if (ret) { dev_err(&hdev->pdev->dev, "VF request to get the pf port media type failed %d",
@@ -342,7 +342,8 @@ static int hclgevf_get_pf_media_type(struct hclgevf_dev *hdev)return ret; } - hdev->hw.mac.media_type = resp_msg; + hdev->hw.mac.media_type = resp_msg[0 ]; + hdev->hw.mac.module_type = resp_msg[1 ];return 0 ; }
@@ -2747,12 +2748,16 @@ static int hclgevf_gro_en(struct hnae3_handle *handle, bool enable)return hclgevf_config_gro (hdev, enable); } -static void hclgevf_get_media_type (struct hnae3_handle *handle, -u8 *media_type) +static void hclgevf_get_media_type (struct hnae3_handle *handle,u8 *media_type, +u8 *module_type) {struct hclgevf_dev *hdev =hclgevf_ae_get_hdev (handle); +if (media_type) *media_type = hdev->hw.mac.media_type; + +if (module_type) + *module_type = hdev->hw.mac.module_type; }static bool hclgevf_get_hw_reset_stat (struct hnae3_handle *handle)
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h +1 -0
@@ -143,6 +143,7 @@ enum hclgevf_states {struct hclgevf_mac {u8 media_type; +u8 module_type;u8 mac_addr[ETH_ALEN ];int link;u8 duplex;
Signature · 1 line
1.9.1
PATCH v2 2/3 net: hns3: add autoneg and change speed support for fibre port
In reply to Peng LiFrom: Jian Shen <[email protected]>
Previously, our driver only supports phydev to autoneg or change port speed. This patch adds support for fibre port, driver gets media speed capability and autoneg capability from firmware. If the media supports multiple speeds, user can change port speed with command "ethtool -s <devname> speed xxxx autoneg off duplex full". If autoneg on, the user configuration may be overwritten by the autoneg result.
--- drivers/net/ethernet/hisilicon/hns3/hnae3.h | 6 ++ drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 90 ++++++++++++++++++++-- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 78 +++++++++++++++++-- 3 files changed, 163 insertions(+), 11 deletions(-)
drivers/net/ethernet/hisilicon/hns3/hnae3.h +6 -0
@@ -244,6 +244,8 @@ struct hnae3_ae_dev {* Get negotiation status,speed and duplex * get_media_type() * Get media type of MAC +* check_port_speed() +* Check target speed whether is supported * adjust_link() * Adjust link status * set_loopback()
@@ -260,6 +262,8 @@ struct hnae3_ae_dev {* set auto autonegotiation of pause frame use * get_autoneg() * get auto autonegotiation of pause frame use +* restart_autoneg() +* restart autonegotiation * get_coalesce_usecs() * get usecs to delay a TX interrupt after a packet is sent * get_rx_max_coalesced_frames()
@@ -355,6 +359,7 @@ struct hnae3_ae_ops {void (*get_media_type)(struct hnae3_handle *handle,u8 *media_type,u8 *module_type); +int (*check_port_speed)(struct hnae3_handle *handle,u32 speed);void (*adjust_link)(struct hnae3_handle *handle,int speed,int duplex);int (*set_loopback)(struct hnae3_handle *handle,enum hnae3_loop loop_mode,bool en);
@@ -370,6 +375,7 @@ struct hnae3_ae_ops {int (*set_autoneg)(struct hnae3_handle *handle,bool enable);int (*get_autoneg)(struct hnae3_handle *handle); +int (*restart_autoneg)(struct hnae3_handle *handle);void (*get_coalesce_usecs)(struct hnae3_handle *handle,u32 *tx_usecs,u32 *rx_usecs);
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +84 -6
120 lines not on this page · raw message
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +73 -5
116 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v2 3/3 net: hns3: add support for FEC encoding control
In reply to Peng LiFrom: Jian Shen <[email protected]>
This patch adds support for FEC encoding control, user can change FEC mode by command ethtool --set-fec, and get FEC mode by command ethtool --show-fec. The fec capability is changed follow the port speed. If autoneg on, the user configure fec mode will be overwritten by autoneg result.
--- drivers/net/ethernet/hisilicon/hns3/hnae3.h | 10 ++ drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 77 +++++++++++++++ .../net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h | 16 ++++ .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 106 +++++++++++++++++++++ .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 5 +- 5 files changed, 213 insertions(+), 1 deletion(-)
drivers/net/ethernet/hisilicon/hns3/hnae3.h +10 -0
@@ -132,6 +132,13 @@ enum hnae3_module_type { }; +enum hnae3_fec_mode { +HNAE3_FEC_AUTO =0 , +HNAE3_FEC_BASER , +HNAE3_FEC_RS , +HNAE3_FEC_USER_DEF , +}; +enum hnae3_reset_notify_type {HNAE3_UP_CLIENT ,HNAE3_DOWN_CLIENT ,
@@ -360,6 +367,9 @@ struct hnae3_ae_ops {void (*get_media_type)(struct hnae3_handle *handle,u8 *media_type,u8 *module_type);int (*check_port_speed)(struct hnae3_handle *handle,u32 speed); +void (*get_fec)(struct hnae3_handle *handle,u8 *fec_ability, +u8 *fec_mode); +int (*set_fec)(struct hnae3_handle *handle,u32 fec_mode);void (*adjust_link)(struct hnae3_handle *handle,int speed,int duplex);int (*set_loopback)(struct hnae3_handle *handle,enum hnae3_loop loop_mode,bool en);
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +77 -0
89 lines not on this page · raw message
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h +16 -0
@@ -113,6 +113,7 @@ enum hclge_opcode_type {HCLGE_OPC_MAC_TNL_INT_EN =0x0311 ,HCLGE_OPC_CLEAR_MAC_TNL_INT =0x0312 ,HCLGE_OPC_SERDES_LOOPBACK =0x0315 , +HCLGE_OPC_CONFIG_FEC_MODE =0x031A ,/* PFC/Pause commands */ HCLGE_OPC_CFG_MAC_PAUSE_EN = 0x0701,
@@ -610,6 +611,21 @@ struct hclge_sfp_info_cmd {u8 rsv[8 ]; }; +#define HCLGE_MAC_CFG_FEC_AUTO_EN_B 0 +#define HCLGE_MAC_CFG_FEC_MODE_S 1 +#define HCLGE_MAC_CFG_FEC_MODE_M GENMASK(3, 1) +#define HCLGE_MAC_CFG_FEC_SET_DEF_B 0 +#define HCLGE_MAC_CFG_FEC_CLR_DEF_B 1 + +#define HCLGE_MAC_FEC_OFF 0 +#define HCLGE_MAC_FEC_BASER 1 +#define HCLGE_MAC_FEC_RS 2 +struct hclge_config_fec_cmd { +u8 fec_mode; +u8 default_config; +u8 rsv[22 ]; +}; +#define HCLGE_MAC_UPLINK_PORT 0x100struct hclge_config_max_frm_size_cmd {
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +106 -0
147 lines not on this page · raw message
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +4 -1
@@ -253,7 +253,10 @@ struct hclge_mac {u32 speed;u32 speed_ability;/* speed ability supported by current media */ u32 module_type;/* sub media type, e.g. kr/cr/sr/lr */ -int link;/* store the link status of mac & phy (if phy exit)*/ +u32 fec_mode;/* active fec mode */ +u32 user_fec_mode; +u32 fec_ability; +int link;/* store the link status of mac & phy (if phy exit) */ struct phy_device *phydev;struct mii_bus *mdio_bus;phy_interface_t phy_if;
Signature · 1 line
1.9.1
David Miller
maintainerFrom: Peng Li <[email protected]>
Date: Fri, 3 May 2019 17:50:36 +0800
Quoted 5 lines
From: Jian Shen <[email protected]>
This patchset enhances more capabilities for fibre port, include multipe media type identification, autoneg, change port speed and FEC encoding.
Series applied.