hinic: add some ethtool ops support
Subsystems (3)
v4 cover hinic: add some ethtool ops support
patch #1: support to set and get pause params with
"ethtool -A/a" cmd
patch #2: support to set and get irq coalesce params with
"ethtool -C/c" cmd
patch #3: support to do self test with "ethtool -t" cmd patch #4: support to identify physical device with "ethtool -p" cmd patch #5: support to get eeprom information with "ethtool -m" cmd
Luo bin (5):
hinic: add support to set and get pause params
hinic: add support to set and get irq coalesce
hinic: add self test support
hinic: add support to identify physical device
hinic: add support to get eeprom information
drivers/net/ethernet/huawei/hinic/hinic_dev.h | 14 + .../net/ethernet/huawei/hinic/hinic_ethtool.c | 600 +++++++++++++++++- .../net/ethernet/huawei/hinic/hinic_hw_dev.c | 66 ++ .../net/ethernet/huawei/hinic/hinic_hw_dev.h | 31 + .../net/ethernet/huawei/hinic/hinic_hw_io.h | 10 + .../net/ethernet/huawei/hinic/hinic_hw_mgmt.h | 7 +- .../net/ethernet/huawei/hinic/hinic_main.c | 128 +++- .../net/ethernet/huawei/hinic/hinic_port.c | 194 ++++++ .../net/ethernet/huawei/hinic/hinic_port.h | 94 +++ drivers/net/ethernet/huawei/hinic/hinic_rx.c | 58 +- .../net/ethernet/huawei/hinic/hinic_sriov.c | 4 +- drivers/net/ethernet/huawei/hinic/hinic_tx.c | 80 +++ drivers/net/ethernet/huawei/hinic/hinic_tx.h | 2 + 13 files changed, 1273 insertions(+), 15 deletions(-)
Signature · 1 line
2.17.1
PATCH v4 1/5 hinic: add support to set and get pause params
add support to set pause params with ethtool -A and get pause params with ethtool -a. Also remove set_link_ksettings ops for VF and enable pause by default.
--- .../net/ethernet/huawei/hinic/hinic_ethtool.c | 86 ++++++++++++++++++- .../net/ethernet/huawei/hinic/hinic_hw_dev.c | 2 + .../net/ethernet/huawei/hinic/hinic_hw_dev.h | 2 + .../net/ethernet/huawei/hinic/hinic_hw_io.h | 10 +++ .../net/ethernet/huawei/hinic/hinic_main.c | 75 +++++++++++++--- .../net/ethernet/huawei/hinic/hinic_port.c | 40 +++++++++ .../net/ethernet/huawei/hinic/hinic_port.h | 13 +++ 7 files changed, 217 insertions(+), 11 deletions(-)
drivers/net/ethernet/huawei/hinic/hinic_ethtool.c +85 -1
@@ -613,6 +613,64 @@ static int hinic_set_ringparam(struct net_device *netdev,return 0 ; } + +static void hinic_get_pauseparam (struct net_device *netdev, +struct ethtool_pauseparam *pause) +{ +struct hinic_dev *nic_dev =netdev_priv (netdev); +struct hinic_pause_config pause_info = {0 }; +struct hinic_nic_cfg *nic_cfg; +int err; + + nic_cfg = &nic_dev->hwdev->func_to_io.nic_cfg; + + err =hinic_get_hw_pause_info (nic_dev->hwdev, &pause_info); +if (!err) { + pause->autoneg = pause_info.auto_neg; +if (nic_cfg->pause_set || !pause_info.auto_neg) { + pause->rx_pause = nic_cfg->rx_pause; + pause->tx_pause = nic_cfg->tx_pause; + }else { + pause->rx_pause = pause_info.rx_pause; + pause->tx_pause = pause_info.tx_pause; + } + } +} + +static int hinic_set_pauseparam (struct net_device *netdev, +struct ethtool_pauseparam *pause) +{ +struct hinic_dev *nic_dev =netdev_priv (netdev); +struct hinic_pause_config pause_info = {0 }; +struct hinic_port_cap port_cap = {0 }; +int err; + + err =hinic_port_get_cap (nic_dev, &port_cap); +if (err) +return -EIO ; + +if (pause->autoneg != port_cap.autoneg_state) +return -EOPNOTSUPP ; + + pause_info.auto_neg = pause->autoneg; + pause_info.rx_pause = pause->rx_pause; + pause_info.tx_pause = pause->tx_pause; + +mutex_lock (&nic_dev->hwdev->func_to_io.nic_cfg.cfg_mutex); + err =hinic_set_hw_pause_info (nic_dev->hwdev, &pause_info); +if (err) { +mutex_unlock (&nic_dev->hwdev->func_to_io.nic_cfg.cfg_mutex); +return err; + } + nic_dev->hwdev->func_to_io.nic_cfg.pause_set = true; + nic_dev->hwdev->func_to_io.nic_cfg.auto_neg = pause->autoneg; + nic_dev->hwdev->func_to_io.nic_cfg.rx_pause = pause->rx_pause; + nic_dev->hwdev->func_to_io.nic_cfg.tx_pause = pause->tx_pause; +mutex_unlock (&nic_dev->hwdev->func_to_io.nic_cfg.cfg_mutex); + +return 0 ; +} +static void hinic_get_channels (struct net_device *netdev,struct ethtool_channels *channels) {
@@ -1241,6 +1299,27 @@ static const struct ethtool_ops hinic_ethtool_ops = { .get_link = ethtool_op_get_link, .get_ringparam = hinic_get_ringparam, .set_ringparam = hinic_set_ringparam, + .get_pauseparam = hinic_get_pauseparam, + .set_pauseparam = hinic_set_pauseparam, + .get_channels = hinic_get_channels, + .set_channels = hinic_set_channels, + .get_rxnfc = hinic_get_rxnfc, + .set_rxnfc = hinic_set_rxnfc, + .get_rxfh_key_size = hinic_get_rxfh_key_size, + .get_rxfh_indir_size = hinic_get_rxfh_indir_size, + .get_rxfh = hinic_get_rxfh, + .set_rxfh = hinic_set_rxfh, + .get_sset_count = hinic_get_sset_count, + .get_ethtool_stats = hinic_get_ethtool_stats, + .get_strings = hinic_get_strings, +}; + +static const struct ethtool_ops hinicvf_ethtool_ops = { + .get_link_ksettings = hinic_get_link_ksettings, + .get_drvinfo = hinic_get_drvinfo, + .get_link = ethtool_op_get_link, + .get_ringparam = hinic_get_ringparam, + .set_ringparam = hinic_set_ringparam, .get_channels = hinic_get_channels, .set_channels = hinic_set_channels, .get_rxnfc = hinic_get_rxnfc,
@@ -1256,5 +1335,10 @@ static const struct ethtool_ops hinic_ethtool_ops = {void hinic_set_ethtool_ops (struct net_device *netdev) { - netdev->ethtool_ops = &hinic_ethtool_ops; +struct hinic_dev *nic_dev =netdev_priv (netdev); + +if (!HINIC_IS_VF (nic_dev->hwdev->hwif)) + netdev->ethtool_ops = &hinic_ethtool_ops; +else + netdev->ethtool_ops = &hinicvf_ethtool_ops; }
drivers/net/ethernet/huawei/hinic/hinic_hw_dev.c +2 -0
@@ -777,6 +777,8 @@ struct hinic_hwdev *hinic_init_hwdev(struct pci_dev *pdev) goto err_dev_cap; } +mutex_init (&hwdev->func_to_io.nic_cfg.cfg_mutex); + err =hinic_vf_func_init (hwdev);if (err) {dev_err (&pdev->dev,"Failed to init nic mbox\n" );
drivers/net/ethernet/huawei/hinic/hinic_hw_dev.h +2 -0
@@ -48,6 +48,8 @@ enum hinic_port_cmd {HINIC_PORT_CMD_ADD_VLAN =3 ,HINIC_PORT_CMD_DEL_VLAN =4 , +HINIC_PORT_CMD_SET_PFC =5 , +HINIC_PORT_CMD_SET_MAC =9 ,HINIC_PORT_CMD_GET_MAC =10 , HINIC_PORT_CMD_DEL_MAC = 11,
drivers/net/ethernet/huawei/hinic/hinic_hw_io.h +10 -0
@@ -47,6 +47,15 @@ struct hinic_free_db_area {struct semaphore idx_lock; }; +struct hinic_nic_cfg { +/* lock for getting nic cfg */ +struct mutex cfg_mutex; +bool pause_set; +u32 auto_neg; +u32 rx_pause; +u32 tx_pause; +}; +struct hinic_func_to_io {struct hinic_hwif *hwif;struct hinic_hwdev *hwdev;
@@ -78,6 +87,7 @@ struct hinic_func_to_io {u16 max_vfs;struct vf_data_storage *vf_infos;u8 link_status; +struct hinic_nic_cfg nic_cfg; };struct hinic_wq_page_size {
drivers/net/ethernet/huawei/hinic/hinic_main.c +65 -10
131 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic/hinic_port.c +40 -0
@@ -1082,6 +1082,7 @@ int hinic_get_link_mode(struct hinic_hwdev *hwdev,if (!hwdev || !link_mode)return -EINVAL ; + link_mode->func_id =HINIC_HWIF_FUNC_IDX (hwdev->hwif); out_size =sizeof (*link_mode); err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_GET_LINK_MODE,
@@ -1172,6 +1173,8 @@ int hinic_get_hw_pause_info(struct hinic_hwdev *hwdev,u16 out_size =sizeof (*pause_info);int err; + pause_info->func_id =HINIC_HWIF_FUNC_IDX (hwdev->hwif); + err =hinic_port_msg_cmd (hwdev,HINIC_PORT_CMD_GET_PAUSE_INFO , pause_info,sizeof (*pause_info), pause_info, &out_size);
@@ -1190,6 +1193,8 @@ int hinic_set_hw_pause_info(struct hinic_hwdev *hwdev,u16 out_size =sizeof (*pause_info);int err; + pause_info->func_id =HINIC_HWIF_FUNC_IDX (hwdev->hwif); + err =hinic_port_msg_cmd (hwdev,HINIC_PORT_CMD_SET_PAUSE_INFO , pause_info,sizeof (*pause_info), pause_info, &out_size);
@@ -1201,3 +1206,38 @@ int hinic_set_hw_pause_info(struct hinic_hwdev *hwdev,return 0 ; } + +int hinic_dcb_set_pfc (struct hinic_hwdev *hwdev,u8 pfc_en,u8 pfc_bitmap) +{ +struct hinic_nic_cfg *nic_cfg = &hwdev->func_to_io.nic_cfg; +struct hinic_set_pfc pfc = {0 }; +u16 out_size =sizeof (pfc); +int err; + +if (HINIC_IS_VF (hwdev->hwif)) +return 0 ; + +mutex_lock (&nic_cfg->cfg_mutex); + + pfc.func_id =HINIC_HWIF_FUNC_IDX (hwdev->hwif); + pfc.pfc_bitmap = pfc_bitmap; + pfc.pfc_en = pfc_en; + + err =hinic_port_msg_cmd (hwdev,HINIC_PORT_CMD_SET_PFC , + &pfc,sizeof (pfc), &pfc, &out_size); +if (err || pfc.status || !out_size) { +dev_err (&hwdev->hwif->pdev->dev,"Failed to %s pfc, err: %d, status: 0x%x, out size: 0x%x\n" , + pfc_en ?"enable" :"disable" , err, pfc.status, + out_size); +mutex_unlock (&nic_cfg->cfg_mutex); +return -EIO ; + } + +/* pause settings is opposite from pfc */ + nic_cfg->rx_pause = pfc_en ?0 :1 ; + nic_cfg->tx_pause = pfc_en ?0 :1 ; + +mutex_unlock (&nic_cfg->cfg_mutex); + +return 0 ; +}
drivers/net/ethernet/huawei/hinic/hinic_port.h +13 -0
@@ -641,6 +641,17 @@ struct hinic_pause_config {u32 tx_pause; }; +struct hinic_set_pfc { +u8 status; +u8 version; +u8 rsvd0[6 ]; + +u16 func_id; +u8 pfc_en; +u8 pfc_bitmap; +u8 rsvd1[4 ]; +}; +int hinic_port_add_mac (struct hinic_dev *nic_dev,const u8 *addr,u16 vlan_id);
@@ -736,6 +747,8 @@ int hinic_get_hw_pause_info(struct hinic_hwdev *hwdev,int hinic_set_hw_pause_info (struct hinic_hwdev *hwdev,struct hinic_pause_config *pause_info); +int hinic_dcb_set_pfc (struct hinic_hwdev *hwdev,u8 pfc_en,u8 pfc_bitmap); +int hinic_open (struct net_device *netdev);int hinic_close (struct net_device *netdev);
Signature · 1 line
2.17.1
PATCH v4 2/5 hinic: add support to set and get irq coalesce
In reply to Luo binadd support to set TX/RX irq coalesce params with ethtool -C and get these params with ethtool -c.
--- drivers/net/ethernet/huawei/hinic/hinic_dev.h | 8 + .../net/ethernet/huawei/hinic/hinic_ethtool.c | 234 ++++++++++++++++++ .../net/ethernet/huawei/hinic/hinic_hw_dev.c | 62 +++++ .../net/ethernet/huawei/hinic/hinic_hw_dev.h | 21 ++ .../net/ethernet/huawei/hinic/hinic_hw_mgmt.h | 3 + .../net/ethernet/huawei/hinic/hinic_main.c | 53 ++++ drivers/net/ethernet/huawei/hinic/hinic_rx.c | 19 +- drivers/net/ethernet/huawei/hinic/hinic_tx.c | 19 ++ 8 files changed, 418 insertions(+), 1 deletion(-)
drivers/net/ethernet/huawei/hinic/hinic_dev.h +8 -0
@@ -49,6 +49,12 @@ enum hinic_rss_hash_type { HINIC_RSS_HASH_ENGINE_TYPE_MAX, }; +struct hinic_intr_coal_info { +u8 pending_limt; +u8 coalesce_timer_cfg; +u8 resend_timer_cfg; +}; +struct hinic_dev {struct net_device *netdev;struct hinic_hwdev *hwdev;
@@ -82,6 +88,8 @@ struct hinic_dev {struct hinic_rss_type rss_type;u8 *rss_hkey_user;s32 *rss_indir_user; +struct hinic_intr_coal_info *rx_intr_coalesce; +struct hinic_intr_coal_info *tx_intr_coalesce;struct hinic_sriov_info sriov_info; };
drivers/net/ethernet/huawei/hinic/hinic_ethtool.c +234 -0
269 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic/hinic_hw_dev.c +62 -0
68 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic/hinic_hw_dev.h +21 -0
@@ -285,6 +285,21 @@ struct hinic_cmd_l2nic_reset {u16 reset_flag; }; +struct hinic_msix_config { +u8 status; +u8 version; +u8 rsvd0[6 ]; + +u16 func_id; +u16 msix_index; +u8 pending_cnt; +u8 coalesce_timer_cnt; +u8 lli_timer_cnt; +u8 lli_credit_cnt; +u8 resend_timer_cnt; +u8 rsvd1[3 ]; +}; +struct hinic_hwdev {struct hinic_hwif *hwif;struct msix_entry *msix_entries;
@@ -378,4 +393,10 @@ int hinic_hwdev_hw_ci_addr_set(struct hinic_hwdev *hwdev, struct hinic_sq *sq,void hinic_hwdev_set_msix_state (struct hinic_hwdev *hwdev,u16 msix_index,enum hinic_msix_state flag); +int hinic_get_interrupt_cfg (struct hinic_hwdev *hwdev, +struct hinic_msix_config *interrupt_info); + +int hinic_set_interrupt_cfg (struct hinic_hwdev *hwdev, +struct hinic_msix_config *interrupt_info); +#endif
drivers/net/ethernet/huawei/hinic/hinic_hw_mgmt.h +3 -0
@@ -78,6 +78,9 @@ enum hinic_comm_cmd {HINIC_COMM_CMD_CEQ_CTRL_REG_WR_BY_UP =0x33 , +HINIC_COMM_CMD_MSI_CTRL_REG_WR_BY_UP , +HINIC_COMM_CMD_MSI_CTRL_REG_RD_BY_UP , +HINIC_COMM_CMD_L2NIC_RESET =0x4b , HINIC_COMM_CMD_PAGESIZE_SET = 0x50,
drivers/net/ethernet/huawei/hinic/hinic_main.c +53 -0
83 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic/hinic_rx.c +18 -1
@@ -478,11 +478,15 @@ static irqreturn_t rx_irq(int irq, void *data)static int rx_request_irq (struct hinic_rxq *rxq) {struct hinic_dev *nic_dev =netdev_priv (rxq->netdev); +struct hinic_msix_config interrupt_info = {0 }; +struct hinic_intr_coal_info *intr_coal =NULL ;struct hinic_hwdev *hwdev = nic_dev->hwdev;struct hinic_rq *rq = rxq->rq;struct hinic_qp *qp;int err; + qp = container_of(rq, struct hinic_qp, rq); +rx_add_napi (rxq); hinic_hwdev_msix_set(hwdev, rq->msix_entry,
@@ -490,13 +494,26 @@ static int rx_request_irq(struct hinic_rxq *rxq)RX_IRQ_NO_LLI_TIMER ,RX_IRQ_NO_CREDIT , RX_IRQ_NO_RESEND_TIMER); + intr_coal = &nic_dev->rx_intr_coalesce[qp->q_id]; + interrupt_info.msix_index = rq->msix_entry; + interrupt_info.coalesce_timer_cnt = intr_coal->coalesce_timer_cfg; + interrupt_info.pending_cnt = intr_coal->pending_limt; + interrupt_info.resend_timer_cnt = intr_coal->resend_timer_cfg; + + err =hinic_set_interrupt_cfg (hwdev, &interrupt_info); +if (err) { +netif_err (nic_dev, drv, rxq->netdev, +"Failed to set RX interrupt coalescing attribute\n" ); +rx_del_napi (rxq); +return err; + } + err =request_irq (rq->irq, rx_irq,0 , rxq->irq_name, rxq);if (err) {rx_del_napi (rxq);return err; } - qp = container_of(rq, struct hinic_qp, rq);cpumask_set_cpu (qp->q_id %num_online_cpus (), &rq->affinity_mask);return irq_set_affinity_hint (rq->irq, &rq->affinity_mask); }
drivers/net/ethernet/huawei/hinic/hinic_tx.c +19 -0
@@ -718,12 +718,17 @@ static irqreturn_t tx_irq(int irq, void *data)static int tx_request_irq (struct hinic_txq *txq) {struct hinic_dev *nic_dev =netdev_priv (txq->netdev); +struct hinic_msix_config interrupt_info = {0 }; +struct hinic_intr_coal_info *intr_coal =NULL ;struct hinic_hwdev *hwdev = nic_dev->hwdev;struct hinic_hwif *hwif = hwdev->hwif;struct pci_dev *pdev = hwif->pdev;struct hinic_sq *sq = txq->sq; +struct hinic_qp *qp;int err; + qp = container_of(sq, struct hinic_qp, sq); +tx_napi_add (txq, nic_dev->tx_weight); hinic_hwdev_msix_set(nic_dev->hwdev, sq->msix_entry,
@@ -731,6 +736,20 @@ static int tx_request_irq(struct hinic_txq *txq)TX_IRQ_NO_LLI_TIMER ,TX_IRQ_NO_CREDIT , TX_IRQ_NO_RESEND_TIMER); + intr_coal = &nic_dev->tx_intr_coalesce[qp->q_id]; + interrupt_info.msix_index = sq->msix_entry; + interrupt_info.coalesce_timer_cnt = intr_coal->coalesce_timer_cfg; + interrupt_info.pending_cnt = intr_coal->pending_limt; + interrupt_info.resend_timer_cnt = intr_coal->resend_timer_cfg; + + err =hinic_set_interrupt_cfg (hwdev, &interrupt_info); +if (err) { +netif_err (nic_dev, drv, txq->netdev, +"Failed to set TX interrupt coalescing attribute\n" ); +tx_napi_del (txq); +return err; + } + err =request_irq (sq->irq, tx_irq,0 , txq->irq_name, txq);if (err) {dev_err (&pdev->dev,"Failed to request Tx irq\n" );
Signature · 1 line
2.17.1
kernel test robot
build botRe: [PATCH net-next v4 2/5] hinic: add support to set and get irq coalesce
Thank you for the patch! Perhaps something to improve:
Hi Luo,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on net-next/master]
url: https://github.com/0day-ci/linux/commits/Luo-bin/hinic-add-some-ethtool-ops-support/20200628-203913 base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 491f14db45dc7fc08ffe00ea6881615638dd159c config: i386-allyesconfig (attached as .config) compiler: gcc-9 (Debian 9.3.0-13) 9.3.0 reproduce (this is a W=1 build): # save the attached .config to linux build tree make W=1 ARCH=i386
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
drivers/net/ethernet/huawei/hinic/hinic_ethtool.c: In function '__hinic_set_coalesce':
>> drivers/net/ethernet/huawei/hinic/hinic_ethtool.c:742:31: warning: variable 'ori_tx_intr_coal' set but not used [-Wunused-but-set-variable]
742 | struct hinic_intr_coal_info *ori_tx_intr_coal = NULL;
| ^~~~~~~~~~~~~~~~
>> drivers/net/ethernet/huawei/hinic/hinic_ethtool.c:741:31: warning: variable 'ori_rx_intr_coal' set but not used [-Wunused-but-set-variable]
741 | struct hinic_intr_coal_info *ori_rx_intr_coal = NULL;
| ^~~~~~~~~~~~~~~~vim +/ori_tx_intr_coal +742 drivers/net/ethernet/huawei/hinic/hinic_ethtool.c
737
738 static int __hinic_set_coalesce(struct net_device *netdev,
739 struct ethtool_coalesce *coal, u16 queue)
740 {
> 741 struct hinic_intr_coal_info *ori_rx_intr_coal = NULL; > 742 struct hinic_intr_coal_info *ori_tx_intr_coal = NULL;
743 struct hinic_dev *nic_dev = netdev_priv(netdev);
744 struct hinic_intr_coal_info rx_intr_coal = {0};
745 struct hinic_intr_coal_info tx_intr_coal = {0};
746 char obj_str[OBJ_STR_MAX_LEN] = {0};
747 bool set_rx_coal = false;
748 bool set_tx_coal = false;
749 int err;
750
751 err = is_coalesce_exceed_limit(coal);
752 if (err)
753 return err;
754
755 if (coal->rx_coalesce_usecs || coal->rx_max_coalesced_frames) {
756 rx_intr_coal.coalesce_timer_cfg =
757 (u8)(coal->rx_coalesce_usecs / COALESCE_TIMER_CFG_UNIT);
758 rx_intr_coal.pending_limt = (u8)(coal->rx_max_coalesced_frames /
759 COALESCE_PENDING_LIMIT_UNIT);
760 set_rx_coal = true;
761 }
762
763 if (coal->tx_coalesce_usecs || coal->tx_max_coalesced_frames) {
764 tx_intr_coal.coalesce_timer_cfg =
765 (u8)(coal->tx_coalesce_usecs / COALESCE_TIMER_CFG_UNIT);
766 tx_intr_coal.pending_limt = (u8)(coal->tx_max_coalesced_frames /
767 COALESCE_PENDING_LIMIT_UNIT);
768 set_tx_coal = true;
769 }
770
771 if (queue == COALESCE_ALL_QUEUE) {
772 ori_rx_intr_coal = &nic_dev->rx_intr_coalesce[0];
773 ori_tx_intr_coal = &nic_dev->tx_intr_coalesce[0];
774 err = snprintf(obj_str, OBJ_STR_MAX_LEN, "for netdev");
775 } else {
776 ori_rx_intr_coal = &nic_dev->rx_intr_coalesce[queue];
777 ori_tx_intr_coal = &nic_dev->tx_intr_coalesce[queue];
778 err = snprintf(obj_str, OBJ_STR_MAX_LEN, "for queue %d", queue);
779 }
780 if (err <= 0 || err >= OBJ_STR_MAX_LEN) {
781 netif_err(nic_dev, drv, netdev, "Failed to snprintf string, function return(%d) and dest_len(%d)\n",
782 err, OBJ_STR_MAX_LEN);
783 return -EFAULT;
784 }
785
786 /* setting coalesce timer or pending limit to zero will disable
787 * coalesce
788 */
789 if (set_rx_coal && (!rx_intr_coal.coalesce_timer_cfg ||
790 !rx_intr_coal.pending_limt))
791 netif_warn(nic_dev, drv, netdev, "RX coalesce will be disabled\n");
792 if (set_tx_coal && (!tx_intr_coal.coalesce_timer_cfg ||
793 !tx_intr_coal.pending_limt))
794 netif_warn(nic_dev, drv, netdev, "TX coalesce will be disabled\n");
795
796 if (set_rx_coal) {
797 err = __set_hw_coal_param(nic_dev, &rx_intr_coal, queue, true);
798 if (err)
799 return err;
800 }
801 if (set_tx_coal) {
802 err = __set_hw_coal_param(nic_dev, &tx_intr_coal, queue, false);
803 if (err)
804 return err;
805 }
806 return 0;
807 }
808
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
PATCH v4 3/5 hinic: add self test support
In reply to Luo binadd support to excute internal and external loopback test with ethtool -t cmd.
--- drivers/net/ethernet/huawei/hinic/hinic_dev.h | 6 + .../net/ethernet/huawei/hinic/hinic_ethtool.c | 177 ++++++++++++++++++ .../net/ethernet/huawei/hinic/hinic_hw_dev.h | 3 + .../net/ethernet/huawei/hinic/hinic_port.c | 27 +++ .../net/ethernet/huawei/hinic/hinic_port.h | 16 ++ drivers/net/ethernet/huawei/hinic/hinic_rx.c | 39 ++++ drivers/net/ethernet/huawei/hinic/hinic_tx.c | 61 ++++++ drivers/net/ethernet/huawei/hinic/hinic_tx.h | 2 + 8 files changed, 331 insertions(+)
drivers/net/ethernet/huawei/hinic/hinic_dev.h +6 -0
@@ -20,11 +20,14 @@#define HINIC_DRV_NAME "hinic" +#define LP_PKT_CNT 64 +enum hinic_flags {HINIC_LINK_UP =BIT (0 ),HINIC_INTF_UP =BIT (1 ),HINIC_RSS_ENABLE =BIT (2 ),HINIC_LINK_DOWN =BIT (3 ), +HINIC_LP_TEST =BIT (4 ), };struct hinic_rx_mode_work {
@@ -91,6 +94,9 @@ struct hinic_dev {struct hinic_intr_coal_info *rx_intr_coalesce;struct hinic_intr_coal_info *tx_intr_coalesce;struct hinic_sriov_info sriov_info; +int lb_test_rx_idx; +int lb_pkt_len; + u8 *lb_test_rx_buf; };#endif
drivers/net/ethernet/huawei/hinic/hinic_ethtool.c +177 -0
213 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic/hinic_hw_dev.h +3 -0
@@ -97,6 +97,9 @@ enum hinic_port_cmd {HINIC_PORT_CMD_FWCTXT_INIT =69 , +HINIC_PORT_CMD_GET_LOOPBACK_MODE =72 , +HINIC_PORT_CMD_SET_LOOPBACK_MODE , +HINIC_PORT_CMD_ENABLE_SPOOFCHK =78 , HINIC_PORT_CMD_GET_MGMT_VERSION = 88,
drivers/net/ethernet/huawei/hinic/hinic_port.c +27 -0
@@ -1241,3 +1241,30 @@ int hinic_dcb_set_pfc(struct hinic_hwdev *hwdev, u8 pfc_en, u8 pfc_bitmap)return 0 ; } + +int hinic_set_loopback_mode (struct hinic_hwdev *hwdev,u32 mode,u32 enable) +{ +struct hinic_port_loopback lb = {0 }; +u16 out_size =sizeof (lb); +int err; + + lb.mode = mode; + lb.en = enable; + +if (mode <LOOP_MODE_MIN || mode >LOOP_MODE_MAX ) { +dev_err (&hwdev->hwif->pdev->dev, +"Invalid loopback mode %d to set\n" , mode); +return -EINVAL ; + } + + err =hinic_port_msg_cmd (hwdev,HINIC_PORT_CMD_SET_LOOPBACK_MODE , + &lb,sizeof (lb), &lb, &out_size); +if (err || !out_size || lb.status) { +dev_err (&hwdev->hwif->pdev->dev, +"Failed to set loopback mode %d en %d, err: %d, status: 0x%x, out size: 0x%x\n" , + mode, enable, err, lb.status, out_size); +return -EIO ; + } + +return 0 ; +}
drivers/net/ethernet/huawei/hinic/hinic_port.h +16 -0
@@ -652,6 +652,20 @@ struct hinic_set_pfc {u8 rsvd1[4 ]; }; +/* get or set loopback mode, need to modify by base API */ +#define HINIC_INTERNAL_LP_MODE 5 +#define LOOP_MODE_MIN 1 +#define LOOP_MODE_MAX 6 + +struct hinic_port_loopback { +u8 status; +u8 version; +u8 rsvd[6 ]; + +u32 mode; +u32 en; +}; +int hinic_port_add_mac (struct hinic_dev *nic_dev,const u8 *addr,u16 vlan_id);
@@ -749,6 +763,8 @@ int hinic_set_hw_pause_info(struct hinic_hwdev *hwdev,int hinic_dcb_set_pfc (struct hinic_hwdev *hwdev,u8 pfc_en,u8 pfc_bitmap); +int hinic_set_loopback_mode (struct hinic_hwdev *hwdev,u32 mode,u32 enable); +int hinic_open (struct net_device *netdev);int hinic_close (struct net_device *netdev);
drivers/net/ethernet/huawei/hinic/hinic_rx.c +39 -0
@@ -316,6 +316,39 @@ static int rx_recv_jumbo_pkt(struct hinic_rxq *rxq, struct sk_buff *head_skb,return num_wqes; } +static void hinic_copy_lp_data (struct hinic_dev *nic_dev, +struct sk_buff *skb) +{ +struct net_device *netdev = nic_dev->netdev; +u8 *lb_buf = nic_dev->lb_test_rx_buf; +int lb_len = nic_dev->lb_pkt_len; +int pkt_offset, frag_len, i; +void *frag_data =NULL ; + +if (nic_dev->lb_test_rx_idx ==LP_PKT_CNT ) { + nic_dev->lb_test_rx_idx =0 ; +netif_warn (nic_dev, drv, netdev,"Loopback test warning, receive too more test pkts\n" ); + } + +if (skb->len != nic_dev->lb_pkt_len) { +netif_warn (nic_dev, drv, netdev,"Wrong packet length\n" ); + nic_dev->lb_test_rx_idx++; +return ; + } + + pkt_offset = nic_dev->lb_test_rx_idx * lb_len; + frag_len = (int )skb_headlen (skb); +memcpy (lb_buf + pkt_offset, skb->data, frag_len); + pkt_offset += frag_len; +for (i =0 ; i <skb_shinfo (skb)->nr_frags; i++) { + frag_data =skb_frag_address (&skb_shinfo (skb)->frags[i]); + frag_len = (int )skb_frag_size (&skb_shinfo (skb)->frags[i]); +memcpy ((lb_buf + pkt_offset), frag_data, frag_len); + pkt_offset += frag_len; + } + nic_dev->lb_test_rx_idx++; +} +/** * rxq_recv - Rx handler * @rxq: rx queue
@@ -330,6 +363,7 @@ static int rxq_recv(struct hinic_rxq *rxq, int budget)u64 pkt_len =0 , rx_bytes =0 ;struct hinic_rq *rq = rxq->rq;struct hinic_rq_wqe *rq_wqe; +struct hinic_dev *nic_dev;unsigned int free_wqebbs;struct hinic_rq_cqe *cqe;int num_wqes, pkts =0 ;
@@ -342,6 +376,8 @@ static int rxq_recv(struct hinic_rxq *rxq, int budget)u32 vlan_len;u16 vid; + nic_dev =netdev_priv (netdev); +while (pkts < budget) { num_wqes =0 ;
@@ -384,6 +420,9 @@ static int rxq_recv(struct hinic_rxq *rxq, int budget)__vlan_hwaccel_put_tag (skb,htons (ETH_P_8021Q ), vid); } +if (unlikely (nic_dev->flags &HINIC_LP_TEST )) +hinic_copy_lp_data (nic_dev, skb); +skb_record_rx_queue (skb, qp->q_id); skb->protocol =eth_type_trans (skb, rxq->netdev);
drivers/net/ethernet/huawei/hinic/hinic_tx.c +61 -0
67 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic/hinic_tx.h +2 -0
@@ -44,6 +44,8 @@ void hinic_txq_clean_stats(struct hinic_txq *txq);void hinic_txq_get_stats (struct hinic_txq *txq,struct hinic_txq_stats *stats); +netdev_tx_t hinic_lb_xmit_frame (struct sk_buff *skb,struct net_device *netdev); +netdev_tx_t hinic_xmit_frame (struct sk_buff *skb,struct net_device *netdev); int hinic_init_txq(struct hinic_txq *txq, struct hinic_sq *sq,
Signature · 1 line
2.17.1
PATCH v4 4/5 hinic: add support to identify physical device
In reply to Luo binadd support to identify physical device by flashing an LED attached to it with ethtool -p cmd.
--- .../net/ethernet/huawei/hinic/hinic_ethtool.c | 34 ++++++++++++ .../net/ethernet/huawei/hinic/hinic_hw_dev.c | 2 + .../net/ethernet/huawei/hinic/hinic_hw_dev.h | 1 + .../net/ethernet/huawei/hinic/hinic_hw_mgmt.h | 4 +- .../net/ethernet/huawei/hinic/hinic_port.c | 55 +++++++++++++++++++ .../net/ethernet/huawei/hinic/hinic_port.h | 35 ++++++++++++ .../net/ethernet/huawei/hinic/hinic_sriov.c | 4 +- 7 files changed, 132 insertions(+), 3 deletions(-)
drivers/net/ethernet/huawei/hinic/hinic_ethtool.c +34 -0
@@ -1684,6 +1684,39 @@ static void hinic_diag_test(struct net_device *netdev,netif_carrier_on (netdev); } +static int hinic_set_phys_id (struct net_device *netdev, +enum ethtool_phys_id_state state) +{ +struct hinic_dev *nic_dev =netdev_priv (netdev); +int err =0 ; +u8 port; + + port = nic_dev->hwdev->port_id; + +switch (state) { +case ETHTOOL_ID_ACTIVE : + err =hinic_set_led_status (nic_dev->hwdev, port, +HINIC_LED_TYPE_LINK , +HINIC_LED_MODE_FORCE_2HZ ); +if (err) +netif_err (nic_dev, drv, netdev, +"Set LED blinking in 2HZ failed\n" ); +break ; + +case ETHTOOL_ID_INACTIVE : + err =hinic_reset_led_status (nic_dev->hwdev, port); +if (err) +netif_err (nic_dev, drv, netdev, +"Reset LED to original status failed\n" ); +break ; + +default : +return -EOPNOTSUPP ; + } + +return err; +} +static const struct ethtool_ops hinic_ethtool_ops = { .supported_coalesce_params =ETHTOOL_COALESCE_RX_USECS | ETHTOOL_COALESCE_RX_MAX_FRAMES |
@@ -1714,6 +1747,7 @@ static const struct ethtool_ops hinic_ethtool_ops = { .get_ethtool_stats = hinic_get_ethtool_stats, .get_strings = hinic_get_strings, .self_test = hinic_diag_test, + .set_phys_id = hinic_set_phys_id, };static const struct ethtool_ops hinicvf_ethtool_ops = {
drivers/net/ethernet/huawei/hinic/hinic_hw_dev.c +2 -0
@@ -83,6 +83,8 @@ static int parse_capability(struct hinic_hwdev *hwdev, nic_cap->max_vf_qps = dev_cap->max_vf_sqs +1 ; } + hwdev->port_id = dev_cap->port_id; +return 0 ; }
drivers/net/ethernet/huawei/hinic/hinic_hw_dev.h +1 -0
@@ -312,6 +312,7 @@ struct hinic_hwdev {struct hinic_mbox_func_to_func *func_to_func;struct hinic_cap nic_cap; +u8 port_id; };struct hinic_nic_cb {
drivers/net/ethernet/huawei/hinic/hinic_hw_mgmt.h +3 -1
@@ -81,7 +81,9 @@ enum hinic_comm_cmd {HINIC_COMM_CMD_MSI_CTRL_REG_WR_BY_UP ,HINIC_COMM_CMD_MSI_CTRL_REG_RD_BY_UP , -HINIC_COMM_CMD_L2NIC_RESET =0x4b , +HINIC_COMM_CMD_SET_LED_STATUS =0x4a , + +HINIC_COMM_CMD_L2NIC_RESET =0x4b , HINIC_COMM_CMD_PAGESIZE_SET = 0x50,
drivers/net/ethernet/huawei/hinic/hinic_port.c +55 -0
58 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic/hinic_port.h +35 -0
@@ -666,6 +666,17 @@ struct hinic_port_loopback {u32 en; }; +struct hinic_led_info { +u8 status; +u8 version; +u8 rsvd0[6 ]; + +u8 port; +u8 type; +u8 mode; +u8 reset; +}; +int hinic_port_add_mac (struct hinic_dev *nic_dev,const u8 *addr,u16 vlan_id);
@@ -765,6 +776,30 @@ int hinic_dcb_set_pfc(struct hinic_hwdev *hwdev, u8 pfc_en, u8 pfc_bitmap);int hinic_set_loopback_mode (struct hinic_hwdev *hwdev,u32 mode,u32 enable); +enum hinic_led_mode { +HINIC_LED_MODE_ON , +HINIC_LED_MODE_OFF , +HINIC_LED_MODE_FORCE_1HZ , +HINIC_LED_MODE_FORCE_2HZ , +HINIC_LED_MODE_FORCE_4HZ , +HINIC_LED_MODE_1HZ , +HINIC_LED_MODE_2HZ , +HINIC_LED_MODE_4HZ , +HINIC_LED_MODE_INVALID , +}; + +enum hinic_led_type { +HINIC_LED_TYPE_LINK , +HINIC_LED_TYPE_LOW_SPEED , +HINIC_LED_TYPE_HIGH_SPEED , +HINIC_LED_TYPE_INVALID , +}; + +int hinic_reset_led_status (struct hinic_hwdev *hwdev,u8 port); + +int hinic_set_led_status (struct hinic_hwdev *hwdev,u8 port, +enum hinic_led_type type,enum hinic_led_mode mode); +int hinic_open (struct net_device *netdev);int hinic_close (struct net_device *netdev);
drivers/net/ethernet/huawei/hinic/hinic_sriov.c +2 -2
@@ -383,7 +383,7 @@ static int hinic_del_vf_mac_msg_handler(void *hwdev, u16 vf_id, nic_io = &hw_dev->func_to_io; vf_info = nic_io->vf_infos +HW_VF_ID_TO_OS (vf_id); -if (vf_info->pf_set_mac &&is_valid_ether_addr (mac_in->mac) && +if (vf_info->pf_set_mac &&is_valid_ether_addr (mac_in->mac) && !memcmp (vf_info->vf_mac_addr, mac_in->mac,ETH_ALEN )) {dev_warn (&hw_dev->hwif->pdev->dev,"PF has already set VF mac.\n" ); mac_out->status =HINIC_PF_SET_VF_ALREADY ;
@@ -905,7 +905,6 @@ int hinic_ndo_set_vf_spoofchk(struct net_device *netdev, int vf, bool setting) err =hinic_set_vf_spoofchk (sriov_info->hwdev,OS_VF_ID_TO_HW (vf), setting); -if (!err) {netif_info (nic_dev, drv, netdev,"Set VF %d spoofchk %s successfully\n" , vf, setting ?"on" :"off" );
@@ -1020,6 +1019,7 @@ static int cfg_mbx_pf_proc_vf_msg(void *hwdev, u16 vf_id, u8 cmd, void *buf_in, dev_cap->max_vf = cap->max_vf; dev_cap->max_sqs = cap->max_vf_qps; dev_cap->max_rqs = cap->max_vf_qps; + dev_cap->port_id = dev->port_id; *out_size =sizeof (*dev_cap);
Signature · 1 line
2.17.1
PATCH v4 5/5 hinic: add support to get eeprom information
In reply to Luo binadd support to get eeprom information from the plug-in module with ethtool -m cmd.
--- .../net/ethernet/huawei/hinic/hinic_ethtool.c | 69 ++++++++++++++++++ .../net/ethernet/huawei/hinic/hinic_hw_dev.h | 4 ++ .../net/ethernet/huawei/hinic/hinic_port.c | 72 +++++++++++++++++++ .../net/ethernet/huawei/hinic/hinic_port.h | 30 ++++++++ 4 files changed, 175 insertions(+)
drivers/net/ethernet/huawei/hinic/hinic_ethtool.c +69 -0
@@ -25,6 +25,7 @@#include <linux/if_vlan.h> #include <linux/ethtool.h> #include <linux/vmalloc.h> +#include <linux/sfp.h> #include "hinic_hw_qp.h" #include "hinic_hw_dev.h"
@@ -1717,6 +1718,72 @@ static int hinic_set_phys_id(struct net_device *netdev,return err; } +static int hinic_get_module_info (struct net_device *netdev, +struct ethtool_modinfo *modinfo) +{ +struct hinic_dev *nic_dev =netdev_priv (netdev); +u8 sfp_type_ext; +u8 sfp_type; +int err; + + err =hinic_get_sfp_type (nic_dev->hwdev, &sfp_type, &sfp_type_ext); +if (err) +return err; + +switch (sfp_type) { +case SFF8024_ID_SFP : + modinfo->type =ETH_MODULE_SFF_8472 ; + modinfo->eeprom_len =ETH_MODULE_SFF_8472_LEN ; +break ; +case SFF8024_ID_QSFP_8438 : + modinfo->type =ETH_MODULE_SFF_8436 ; + modinfo->eeprom_len =ETH_MODULE_SFF_8436_MAX_LEN ; +break ; +case SFF8024_ID_QSFP_8436_8636 : +if (sfp_type_ext >=0x3 ) { + modinfo->type =ETH_MODULE_SFF_8636 ; + modinfo->eeprom_len =ETH_MODULE_SFF_8636_MAX_LEN ; + + }else { + modinfo->type =ETH_MODULE_SFF_8436 ; + modinfo->eeprom_len =ETH_MODULE_SFF_8436_MAX_LEN ; + } +break ; +case SFF8024_ID_QSFP28_8636 : + modinfo->type =ETH_MODULE_SFF_8636 ; + modinfo->eeprom_len =ETH_MODULE_SFF_8636_MAX_LEN ; +break ; +default : +netif_warn (nic_dev, drv, netdev, +"Optical module unknown: 0x%x\n" , sfp_type); +return -EINVAL ; + } + +return 0 ; +} + +static int hinic_get_module_eeprom (struct net_device *netdev, +struct ethtool_eeprom *ee,u8 *data) +{ +struct hinic_dev *nic_dev =netdev_priv (netdev); +u8 sfp_data[STD_SFP_INFO_MAX_SIZE ]; +u16 len; +int err; + +if (!ee->len || ((ee->len + ee->offset) >STD_SFP_INFO_MAX_SIZE )) +return -EINVAL ; + +memset (data,0 , ee->len); + + err =hinic_get_sfp_eeprom (nic_dev->hwdev, sfp_data, &len); +if (err) +return err; + +memcpy (data, sfp_data + ee->offset, ee->len); + +return 0 ; +} +static const struct ethtool_ops hinic_ethtool_ops = { .supported_coalesce_params =ETHTOOL_COALESCE_RX_USECS | ETHTOOL_COALESCE_RX_MAX_FRAMES |
@@ -1748,6 +1815,8 @@ static const struct ethtool_ops hinic_ethtool_ops = { .get_strings = hinic_get_strings, .self_test = hinic_diag_test, .set_phys_id = hinic_set_phys_id, + .get_module_info = hinic_get_module_info, + .get_module_eeprom = hinic_get_module_eeprom, };static const struct ethtool_ops hinicvf_ethtool_ops = {
drivers/net/ethernet/huawei/hinic/hinic_hw_dev.h +4 -0
@@ -130,9 +130,13 @@ enum hinic_port_cmd {HINIC_PORT_CMD_SET_AUTONEG =219 , +HINIC_PORT_CMD_GET_STD_SFP_INFO =240 , +HINIC_PORT_CMD_SET_LRO_TIMER =244 ,HINIC_PORT_CMD_SET_VF_MAX_MIN_RATE =249 , + + HINIC_PORT_CMD_GET_SFP_ABS = 251, };/* cmd of mgmt CPU message for HILINK module */
drivers/net/ethernet/huawei/hinic/hinic_port.c +72 -0
75 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic/hinic_port.h +30 -0
@@ -677,6 +677,32 @@ struct hinic_led_info {u8 reset; }; +#define STD_SFP_INFO_MAX_SIZE 640 + +struct hinic_cmd_get_light_module_abs { +u8 status; +u8 version; +u8 rsvd0[6 ]; + +u8 port_id; +u8 abs_status;/* 0:present, 1:absent */ +u8 rsv[2 ]; +}; + +#define STD_SFP_INFO_MAX_SIZE 640 + +struct hinic_cmd_get_std_sfp_info { +u8 status; +u8 version; +u8 rsvd0[6 ]; + +u8 port_id; +u8 wire_type; +u16 eeprom_len; +u32 rsvd; +u8 sfp_info[STD_SFP_INFO_MAX_SIZE ]; +}; +int hinic_port_add_mac (struct hinic_dev *nic_dev,const u8 *addr,u16 vlan_id);
@@ -800,6 +826,10 @@ int hinic_reset_led_status(struct hinic_hwdev *hwdev, u8 port);int hinic_set_led_status (struct hinic_hwdev *hwdev,u8 port,enum hinic_led_type type,enum hinic_led_mode mode); +int hinic_get_sfp_type (struct hinic_hwdev *hwdev,u8 *data0,u8 *data1); + +int hinic_get_sfp_eeprom (struct hinic_hwdev *hwdev,u8 *data,u16 *len); +int hinic_open (struct net_device *netdev);int hinic_close (struct net_device *netdev);
Signature · 1 line
2.17.1
David Miller
maintainerFrom: Luo bin <[email protected]>
Date: Sun, 28 Jun 2020 20:36:19 +0800
Quoted 7 lines
patch #1: support to set and get pause params with
"ethtool -A/a" cmd
patch #2: support to set and get irq coalesce params with
"ethtool -C/c" cmd
patch #3: support to do self test with "ethtool -t" cmd patch #4: support to identify physical device with "ethtool -p" cmd patch #5: support to get eeprom information with "ethtool -m" cmd
Series applied, thank you.