net: thunderx: Miscellaneous fixes
Subsystems (3)
v2 cover net: thunderx: Miscellaneous fixes
From: Sunil Goutham <[email protected]>
This patch series contains fixes for various issues observed with BGX and NIC drivers.
Changes from v1:
- Fixed comment syle in the first patch of the series
- Removed 'Increase transmit queue length' patch from the series, will recheck if it's a driver or system issue and resubmit.
Sunil Goutham (3):
net: thunderx: Set CQ timer threshold properly
net: thunderx: Switchon carrier only upon interface link up
net: thunderx: Enable BGX LMAC's RX/TX only after VF is up
Thanneeru Srinivasulu (2):
net: thunderx: Force to load octeon-mdio before bgx driver.
net: thunderx: Wait for delayed work to finish before destroying it
drivers/net/ethernet/cavium/thunder/nic.h | 5 +-- drivers/net/ethernet/cavium/thunder/nic_main.c | 23 ++++++++++++++-- .../net/ethernet/cavium/thunder/nicvf_ethtool.c | 16 ++++++++++- drivers/net/ethernet/cavium/thunder/nicvf_main.c | 4 +-- drivers/net/ethernet/cavium/thunder/nicvf_queues.c | 2 +- drivers/net/ethernet/cavium/thunder/nicvf_queues.h | 2 +- drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 28 +++++++++++++++++--- drivers/net/ethernet/cavium/thunder/thunder_bgx.h | 2 + 8 files changed, 66 insertions(+), 16 deletions(-)
PATCH v2 1/5 net: thunderx: Force to load octeon-mdio before bgx driver.
From: Thanneeru Srinivasulu <[email protected]>
--- drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 3 +++ drivers/net/ethernet/cavium/thunder/thunder_bgx.h | 1 + 2 files changed, 4 insertions(+), 0 deletions(-)
drivers/net/ethernet/cavium/thunder/thunder_bgx.c +3 -0
@@ -1009,6 +1009,9 @@ static int bgx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)struct bgx *bgx =NULL ;u8 lmac; +/* Load octeon mdio driver */ +octeon_mdiobus_force_mod_depencency (); + bgx =devm_kzalloc (dev,sizeof (*bgx),GFP_KERNEL );if (!bgx)return -ENOMEM ;
drivers/net/ethernet/cavium/thunder/thunder_bgx.h +1 -0
@@ -182,6 +182,7 @@ enum MCAST_MODE {#define BCAST_ACCEPT 1#define CAM_ACCEPT 1 +void octeon_mdiobus_force_mod_depencency (void );void bgx_add_dmac_addr (u64 dmac,int node,int bgx_idx,int lmac);unsigned bgx_get_map (int node);int bgx_get_lmac_count (int node,int bgx);
Signature · 1 line
1.7.1
PATCH v2 2/5 net: thunderx: Wait for delayed work to finish before destroying it
In reply to Sunil GouthamFrom: Thanneeru Srinivasulu <[email protected]>
While VNIC or BGX driver teardown, wait for already scheduled delayed work to finish before destroying it.
--- drivers/net/ethernet/cavium/thunder/nic_main.c | 3 +-- drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/net/ethernet/cavium/thunder/nic_main.c +1 -2
@@ -1074,8 +1074,7 @@ static void nic_remove(struct pci_dev *pdev)if (nic->check_link) {/* Destroy work Queue */ -cancel_delayed_work (&nic->dwork); -flush_workqueue (nic->check_link); +cancel_delayed_work_sync (&nic->dwork);destroy_workqueue (nic->check_link); }
drivers/net/ethernet/cavium/thunder/thunder_bgx.c +1 -2
@@ -695,8 +695,7 @@ static void bgx_lmac_disable(struct bgx *bgx, u8 lmacid) lmac = &bgx->lmac[lmacid];if (lmac->check_link) {/* Destroy work queue */ -cancel_delayed_work (&lmac->dwork); -flush_workqueue (lmac->check_link); +cancel_delayed_work_sync (&lmac->dwork);destroy_workqueue (lmac->check_link); }
Signature · 1 line
1.7.1
PATCH v2 3/5 net: thunderx: Set CQ timer threshold properly
In reply to Sunil GouthamFrom: Sunil Goutham <[email protected]>
Properly set CQ timer threshold and also set it to 2us.
With previous incorrect settings it was set to 0.5us which is too less.
--- drivers/net/ethernet/cavium/thunder/nic.h | 5 ++--- drivers/net/ethernet/cavium/thunder/nicvf_queues.c | 2 +- drivers/net/ethernet/cavium/thunder/nicvf_queues.h | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-)
drivers/net/ethernet/cavium/thunder/nic.h +2 -3
@@ -120,10 +120,9 @@* Calculated for SCLK of 700Mhz * value written should be a 1/16th of what is expected * -* 1 tick per 0.05usec = value of 2.2 -* This 10% would be covered in CQ timer thresh value +* 1 tick per 0.025usec */ -#define NICPF_CLK_PER_INT_TICK 2 +#define NICPF_CLK_PER_INT_TICK 1/* Time to wait before we decide that a SQ is stuck. *
drivers/net/ethernet/cavium/thunder/nicvf_queues.c +1 -1
@@ -592,7 +592,7 @@ void nicvf_cmp_queue_config(struct nicvf *nic, struct queue_set *qs,/* Set threshold value for interrupt generation */ nicvf_queue_reg_write (nic,NIC_QSET_CQ_0_7_THRESH , qidx, cq->thresh);nicvf_queue_reg_write (nic,NIC_QSET_CQ_0_7_CFG2 , - qidx, nic->cq_coalesce_usecs); + qidx,CMP_QUEUE_TIMER_THRESH ); }/* Configures transmit queue */
drivers/net/ethernet/cavium/thunder/nicvf_queues.h +1 -1
@@ -76,7 +76,7 @@#define CMP_QSIZE CMP_QUEUE_SIZE2#define CMP_QUEUE_LEN (1ULL << (CMP_QSIZE + 10))#define CMP_QUEUE_CQE_THRESH 0 -#define CMP_QUEUE_TIMER_THRESH 220/* 10usec */ +#define CMP_QUEUE_TIMER_THRESH 80/* ~2usec */ #define RBDR_SIZE RBDR_SIZE0#define RCV_BUF_COUNT (1ULL << (RBDR_SIZE + 13))
Signature · 1 line
1.7.1
PATCH v2 4/5 net: thunderx: Switchon carrier only upon interface link up
In reply to Sunil GouthamFrom: Sunil Goutham <[email protected]>
Call netif_carrier_on() only if interface's link is up. Switching this on upon IFF_UP by default, is causing issues with ethernet channel bonding in LACP mode. Initial NETDEV_CHANGE notification was being skipped.
Also fixed some issues with link/speed/duplex reporting via ethtool.
--- .../net/ethernet/cavium/thunder/nicvf_ethtool.c | 16 +++++++++++++++- drivers/net/ethernet/cavium/thunder/nicvf_main.c | 4 +--- drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 2 ++ 3 files changed, 18 insertions(+), 4 deletions(-)
drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c +15 -1
@@ -112,6 +112,13 @@ static int nicvf_get_settings(struct net_device *netdev, cmd->supported =0 ; cmd->transceiver =XCVR_EXTERNAL ; + +if (!nic->link_up) { + cmd->duplex =DUPLEX_UNKNOWN ; +ethtool_cmd_speed_set (cmd,SPEED_UNKNOWN ); +return 0 ; + } +if (nic->speed <=1000 ) { cmd->port =PORT_MII ; cmd->autoneg =AUTONEG_ENABLE ;
@@ -125,6 +132,13 @@ static int nicvf_get_settings(struct net_device *netdev,return 0 ; } +static u32 nicvf_get_link (struct net_device *netdev) +{ +struct nicvf *nic =netdev_priv (netdev); + +return nic->link_up; +} +static void nicvf_get_drvinfo (struct net_device *netdev,struct ethtool_drvinfo *info) {
@@ -660,7 +674,7 @@ static int nicvf_set_channels(struct net_device *dev,static const struct ethtool_ops nicvf_ethtool_ops = { .get_settings = nicvf_get_settings, - .get_link = ethtool_op_get_link, + .get_link = nicvf_get_link, .get_drvinfo = nicvf_get_drvinfo, .get_msglevel = nicvf_get_msglevel, .set_msglevel = nicvf_set_msglevel,
drivers/net/ethernet/cavium/thunder/nicvf_main.c +1 -3
@@ -1057,6 +1057,7 @@ int nicvf_stop(struct net_device *netdev)netif_carrier_off (netdev);netif_tx_stop_all_queues (nic->netdev); + nic->link_up = false;/* Teardown secondary qsets first */ if (!nic->sqs_mode) {
@@ -1211,9 +1212,6 @@ int nicvf_open(struct net_device *netdev) nic->drv_stats.txq_stop =0 ; nic->drv_stats.txq_wake =0 ; -netif_carrier_on (netdev); -netif_tx_start_all_queues (netdev); -return 0 ; cleanup:nicvf_disable_intr (nic,NICVF_INTR_MBOX ,0 );
drivers/net/ethernet/cavium/thunder/thunder_bgx.c +2 -0
@@ -612,6 +612,8 @@ static void bgx_poll_for_link(struct work_struct *work) lmac->last_duplex =1 ; }else { lmac->link_up =0 ; + lmac->last_speed =SPEED_UNKNOWN ; + lmac->last_duplex =DUPLEX_UNKNOWN ; }if (lmac->last_link != lmac->link_up) {
Signature · 1 line
1.7.1
RE: [PATCH v2 4/5] net: thunderx: Switchon carrier only upon interface link up
Just a reminder, we have issue with this one too, which is not addressed yet.
Kind regards,
Pavel Fedin
Expert Engineer
Samsung Electronics Research center Russia
Quoted 110 lines
-----Original Message-----
From: netdev-owner at vger.kernel.org [mailto:netdev-owner at vger.kernel.org] On Behalf Of Sunil Goutham
Sent: Wednesday, December 02, 2015 1:06 PM
To: netdev at vger.kernel.org
Cc: linux-kernel at vger.kernel.org; linux-arm-kernel at lists.infradead.org; Sunil.Goutham at caviumnetworks.com; Sunil Goutham
Subject: [PATCH v2 4/5] net: thunderx: Switchon carrier only upon interface link upFrom: Sunil Goutham <[email protected]>
Call
netif_carrier_on()only if interface's link is up. Switching this on uponIFF_UPby default, is causing issues with ethernet channel bonding in LACP mode. InitialNETDEV_CHANGEnotification was being skipped.Also fixed some issues with link/speed/duplex reporting via ethtool.
Signed-off-by Sunil Goutham <[email protected]>--- .../net/ethernet/cavium/thunder/nicvf_ethtool.c | 16 +++++++++++++++- drivers/net/ethernet/cavium/thunder/nicvf_main.c | 4 +--- drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 2 ++ 3 files changed, 18 insertions(+), 4 deletions(-)drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c +15
-1@@ -112,6 +112,13 @@ static int nicvf_get_settings(struct net_device *netdev, cmd->supported =0 ; cmd->transceiver =XCVR_EXTERNAL ; + +if (!nic->link_up) { + cmd->duplex =DUPLEX_UNKNOWN ; +ethtool_cmd_speed_set (cmd,SPEED_UNKNOWN ); +return 0 ; + } +if (nic->speed <=1000 ) { cmd->port =PORT_MII ; cmd->autoneg =AUTONEG_ENABLE ;@@ -125,6 +132,13 @@ static int nicvf_get_settings(struct net_device *netdev,return 0 ; } +static u32 nicvf_get_link (struct net_device *netdev) +{ +struct nicvf *nic =netdev_priv (netdev); + +return nic->link_up; +} +static void nicvf_get_drvinfo (struct net_device *netdev,struct ethtool_drvinfo *info) {@@ -660,7 +674,7 @@ static int nicvf_set_channels(struct net_device *dev,static const struct ethtool_ops nicvf_ethtool_ops = { .get_settings = nicvf_get_settings, - .get_link = ethtool_op_get_link, + .get_link = nicvf_get_link, .get_drvinfo = nicvf_get_drvinfo, .get_msglevel = nicvf_get_msglevel, .set_msglevel = nicvf_set_msglevel,drivers/net/ethernet/cavium/thunder/nicvf_main.c +1
-3@@ -1057,6 +1057,7 @@ int nicvf_stop(struct net_device *netdev)netif_carrier_off (netdev);netif_tx_stop_all_queues (nic->netdev); + nic->link_up = false;/* Teardown secondary qsets first */ if (!nic->sqs_mode) {@@ -1211,9 +1212,6 @@ int nicvf_open(struct net_device *netdev) nic->drv_stats.txq_stop =0 ; nic->drv_stats.txq_wake =0 ; -netif_carrier_on (netdev); -netif_tx_start_all_queues (netdev); -return 0 ; cleanup:nicvf_disable_intr (nic,NICVF_INTR_MBOX ,0 );drivers/net/ethernet/cavium/thunder/thunder_bgx.c +2
-1@@ -612,6 +612,8 @@ static void bgx_poll_for_link(struct work_struct *work) lmac->last_duplex =1 ; }else { lmac->link_up =0 ; + lmac->last_speed =SPEED_UNKNOWN ; + lmac->last_duplex =DUPLEX_UNKNOWN ; }if (lmac->last_link != lmac->link_up) { --1.7.1
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Pavel Fedin
Tested-byRE: [PATCH v2 4/5] net: thunderx: Switchon carrier only upon interface link up
Hello again!
Quoted 3 lines
Subject: RE: [PATCH v2 4/5] net: thunderx: Switchon carrier only upon interface link up
Just a reminder, we have issue with this one too, which is not addressed yet.
I have examined the problem thoroughly and discovered that it is a problem with experimental BGX driver patches on my 4.2 host
kernel build. It fails to send NIC_MBOX_MSG_BGX_LINK_CHANGE, so nothing works.
I have retested this series on top of 4.3 running on ThunderX. It has good BGX driver and everything works fine. Therefore, the
whole series can be safely applied and...
Kind regards,
Pavel Fedin
Expert Engineer
Samsung Electronics Research center Russia
Re: [PATCH v2 4/5] net: thunderx: Switchon carrier only upon interface link up
Thanks for the confirmation.
Quoted 19 lines · Pavel Fedin
Hello again!
Quoted 3 lines
Subject: RE: [PATCH v2 4/5] net: thunderx: Switchon carrier only upon interface link up
Just a reminder, we have issue with this one too, which is not addressed yet.
I have examined the problem thoroughly and discovered that it is a problem with experimental BGX driver patches on my 4.2 host
kernel build. It fails to sendNIC_MBOX_MSG_BGX_LINK_CHANGE, so nothing works.
I have retested this series on top of 4.3 running on ThunderX. It has good BGX driver and everything works fine. Therefore, the
whole series can be safely applied and...Tested-by Pavel Fedin <[email protected]>Kind regards,
Pavel Fedin
Expert Engineer
Samsung Electronics Research center Russia
David Miller
maintainerRe: [PATCH v2 4/5] net: thunderx: Switchon carrier only upon interface link up
In reply to Pavel FedinFrom: Pavel Fedin <[email protected]>
Date: Wed, 02 Dec 2015 14:30:37 +0300
Quoted 4 lines
Hello again!
Quoted 2 lines
Subject: RE: [PATCH v2 4/5] net: thunderx: Switchon carrier only upon interface link up
Quoted 8 lines
Quoted 1 line
Just a reminder, we have issue with this one too, which is not addressed yet.
I have examined the problem thoroughly and discovered that it is a problem with experimental BGX driver patches on my 4.2 host
kernel build. It fails to sendNIC_MBOX_MSG_BGX_LINK_CHANGE, so nothing works.
I have retested this series on top of 4.3 running on ThunderX. It has good BGX driver and everything works fine. Therefore, the
whole series can be safely applied and...Tested-by Pavel Fedin <[email protected]>
Ok, thanks for confirming things are fine now.
I'll apply this series.
PATCH v2 5/5 net: thunderx: Enable BGX LMAC's RX/TX only after VF is up
In reply to Sunil GouthamFrom: Sunil Goutham <[email protected]>
Enable or disable BGX LMAC's RX/TX based on corresponding VF's status. If otherwise, when multiple LMAC's physical link is up then packets from all LMAC's whose corresponding VF is not yet initialized will get forwarded to VF0. This is due to VNIC's default configuration where CPI, RSSI e.t.c point to VF0/QSET0/RQ0.
This patch will prevent multiple copies of packets on VF0.
--- drivers/net/ethernet/cavium/thunder/nic_main.c | 20 +++++++++++++++++++- drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 20 ++++++++++++++++++-- drivers/net/ethernet/cavium/thunder/thunder_bgx.h | 1 + 3 files changed, 38 insertions(+), 3 deletions(-)
drivers/net/ethernet/cavium/thunder/nic_main.c +19 -1
@@ -37,6 +37,7 @@ struct nicpf {#define NIC_GET_BGX_FROM_VF_LMAC_MAP (map) ((map >> 4) & 0xF)#define NIC_GET_LMAC_FROM_VF_LMAC_MAP (map) (map & 0xF)u8 vf_lmac_map[MAX_LMAC ]; +u8 lmac_cnt;struct delayed_work dwork;struct workqueue_struct *check_link;u8 link[MAX_LMAC ];
@@ -279,6 +280,7 @@ static void nic_set_lmac_vf_mapping(struct nicpf *nic)u64 lmac_credit; nic->num_vf_en =0 ; + nic->lmac_cnt =0 ;for (bgx =0 ; bgx <NIC_MAX_BGX ; bgx++) {if (!(bgx_map & (1 << bgx)))
@@ -288,6 +290,7 @@ static void nic_set_lmac_vf_mapping(struct nicpf *nic) nic->vf_lmac_map[next_bgx_lmac++] =NIC_SET_VF_LMAC_MAP (bgx, lmac); nic->num_vf_en += lmac_cnt; + nic->lmac_cnt += lmac_cnt;/* Program LMAC credits */ lmac_credit = (1ull <<1 );/* channel credit enable */
@@ -715,6 +718,13 @@ static void nic_handle_mbx_intr(struct nicpf *nic, int vf)case NIC_MBOX_MSG_CFG_DONE :/* Last message of VF config msg sequence */ nic->vf_enabled[vf] = true; +if (vf >= nic->lmac_cnt) + goto unlock; + + bgx =NIC_GET_BGX_FROM_VF_LMAC_MAP (nic->vf_lmac_map[vf]); + lmac =NIC_GET_LMAC_FROM_VF_LMAC_MAP (nic->vf_lmac_map[vf]); + +bgx_lmac_rx_tx_enable (nic->node, bgx, lmac, true); goto unlock;case NIC_MBOX_MSG_SHUTDOWN :/* First msg in VF teardown sequence */
@@ -722,6 +732,14 @@ static void nic_handle_mbx_intr(struct nicpf *nic, int vf)if (vf >= nic->num_vf_en) nic->sqs_used[vf - nic->num_vf_en] = false; nic->pqs_vf[vf] =0 ; + +if (vf >= nic->lmac_cnt) +break ; + + bgx =NIC_GET_BGX_FROM_VF_LMAC_MAP (nic->vf_lmac_map[vf]); + lmac =NIC_GET_LMAC_FROM_VF_LMAC_MAP (nic->vf_lmac_map[vf]); + +bgx_lmac_rx_tx_enable (nic->node, bgx, lmac, false);break ;case NIC_MBOX_MSG_ALLOC_SQS :nic_alloc_sqs (nic, &mbx.sqs_alloc);
@@ -940,7 +958,7 @@ static void nic_poll_for_link(struct work_struct *work) mbx.link_status.msg =NIC_MBOX_MSG_BGX_LINK_CHANGE ; -for (vf =0 ; vf < nic->num_vf_en; vf++) { +for (vf =0 ; vf < nic->lmac_cnt; vf++) {/* Poll only if VF is UP */ if (!nic->vf_enabled[vf])continue ;
drivers/net/ethernet/cavium/thunder/thunder_bgx.c +18 -2
@@ -186,6 +186,23 @@ void bgx_set_lmac_mac(int node, int bgx_idx, int lmacid, const u8 *mac) }EXPORT_SYMBOL (bgx_set_lmac_mac); +void bgx_lmac_rx_tx_enable (int node,int bgx_idx,int lmacid,bool enable) +{ +struct bgx *bgx = bgx_vnic[(node *MAX_BGX_PER_CN88XX ) + bgx_idx]; +u64 cfg; + +if (!bgx) +return ; + + cfg =bgx_reg_read (bgx, lmacid,BGX_CMRX_CFG ); +if (enable) + cfg |=CMR_PKT_RX_EN |CMR_PKT_TX_EN ; +else + cfg &= ~(CMR_PKT_RX_EN |CMR_PKT_TX_EN ); +bgx_reg_write (bgx, lmacid,BGX_CMRX_CFG , cfg); +} +EXPORT_SYMBOL (bgx_lmac_rx_tx_enable); +static void bgx_sgmii_change_link_state (struct lmac *lmac) {struct bgx *bgx = lmac->bgx;
@@ -656,8 +673,7 @@ static int bgx_lmac_enable(struct bgx *bgx, u8 lmacid) }/* Enable lmac */ -bgx_reg_modify (bgx, lmacid,BGX_CMRX_CFG , -CMR_EN |CMR_PKT_RX_EN |CMR_PKT_TX_EN ); +bgx_reg_modify (bgx, lmacid,BGX_CMRX_CFG ,CMR_EN );/* Restore default cfg, incase low level firmware changed it */ bgx_reg_write (bgx, lmacid,BGX_CMRX_RX_DMAC_CTL ,0x03 );
drivers/net/ethernet/cavium/thunder/thunder_bgx.h +1 -0
@@ -183,6 +183,7 @@ enum MCAST_MODE {#define CAM_ACCEPT 1void octeon_mdiobus_force_mod_depencency (void ); +void bgx_lmac_rx_tx_enable (int node,int bgx_idx,int lmacid,bool enable);void bgx_add_dmac_addr (u64 dmac,int node,int bgx_idx,int lmac);unsigned bgx_get_map (int node);int bgx_get_lmac_count (int node,int bgx);
Signature · 1 line
1.7.1
David Miller
maintainerI'm not even looking at this patch series while it still causes unresolved bugs.