IB/hfi1: Minor and misc bug fixes
Subsystems (2)
cover IB/hfi1: Minor and misc bug fixes
Hi Jason and Doug,
Here are some fixes for minor issues. Minor in terms of severity, not necessarily in terms of complexity. The diffstat for mad.c in particular looks pretty bad but it's basically changing the units being used from cycle time to flit time.
This is a resubmit of my previous patch set [1] broken up into smaller logically grouped patch sets.
As always my GitHub had these in-tree for context:
https://github.com/ddalessa/kernel/tree/for-4.16
[1] https://www.spinics.net/lists/linux-rdma/msg60011.html
---
Bartlomiej Dudek (1):
IB/hfi1: Do not override given pcie_pset value
Kamenee Arumugam (1):
IB/hfi1: Convert PortXmitWait/PortVLXmitWait counters to flit times
Mike Marciniszyn (1):
IB/hfi1: Remove blind constants from 16B update
Mitko Haralanov (1):
IB/hfi1: Show fault stats in both TX and RX directions
drivers/infiniband/hw/hfi1/chip.c | 64 ++++++++++++++++- drivers/infiniband/hw/hfi1/chip.h | 4 + drivers/infiniband/hw/hfi1/debugfs.c | 9 ++ drivers/infiniband/hw/hfi1/driver.c | 6 +- drivers/infiniband/hw/hfi1/hfi.h | 7 ++ drivers/infiniband/hw/hfi1/init.c | 9 ++ drivers/infiniband/hw/hfi1/mad.c | 127 +++++++++++++++++++++++++++++++--- drivers/infiniband/hw/hfi1/mad.h | 47 ++++++++++++- drivers/infiniband/hw/hfi1/pcie.c | 23 +++--- drivers/infiniband/hw/hfi1/ruc.c | 13 ++- drivers/infiniband/hw/hfi1/ud.c | 15 +++- drivers/infiniband/hw/hfi1/verbs.h | 5 + 12 files changed, 284 insertions(+), 45 deletions(-)
--
-Denny
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 20180201184921.7300.11118.stgit-9QXIwq+3FY+1XWohqUldA0EOCMrvLtNR@public.gmane.org
PATCH 1/4 IB/hfi1: Do not override given pcie_pset value
From: Bartlomiej Dudek <[email protected]>
During PCIe Gen 3 transistion, pcie_pset is read and might be overridden to a default value(i.e. 255) in do_pcie_gen3_transition() routine.
If the pcie_pset value is overridden then this new value will be used during initialization of next adapter on a different card.
Introducing a new local variable to avoid modification of pcie_pset
--- drivers/infiniband/hw/hfi1/pcie.c | 23 ++++++++++++----------- 1 files changed, 12 insertions(+), 11 deletions(-)
drivers/infiniband/hw/hfi1/pcie.c +12 -11
@@ -1034,6 +1034,7 @@ int do_pcie_gen3_transition(struct hfi1_devdata *dd)int do_retry, retry_count =0 ;int intnum =0 ;uint default_pset; +uint pset = pcie_pset;u16 target_vector, target_speed;u16 lnkctl2, vendor;u8 div;
@@ -1201,16 +1202,16 @@ int do_pcie_gen3_transition(struct hfi1_devdata *dd)* * Set Gen3EqPsetReqVec, leave other fields 0. */ -if (pcie_pset ==UNSET_PSET ) - pcie_pset = default_pset; -if (pcie_pset >10 ) {/* valid range is 0-10, inclusive */ +if (pset ==UNSET_PSET ) + pset = default_pset; +if (pset >10 ) {/* valid range is 0-10, inclusive */ dd_dev_err (dd,"%s: Invalid Eq Pset %u, setting to %d\n" , - __func__, pcie_pset, default_pset); - pcie_pset = default_pset; + __func__, pset, default_pset); + pset = default_pset; } -dd_dev_info (dd,"%s: using EQ Pset %u\n" , __func__, pcie_pset); +dd_dev_info (dd,"%s: using EQ Pset %u\n" , __func__, pset);pci_write_config_dword (dd->pcidev,PCIE_CFG_REG_PL106 , - ((1 << pcie_pset) << + ((1 << pset) <<PCIE_CFG_REG_PL106_GEN3_EQ_PSET_REQ_VEC_SHIFT ) |PCIE_CFG_REG_PL106_GEN3_EQ_EVAL2MS_DISABLE_SMASK |PCIE_CFG_REG_PL106_GEN3_EQ_PHASE23_EXIT_MODE_SMASK );
@@ -1240,10 +1241,10 @@ int do_pcie_gen3_transition(struct hfi1_devdata *dd)/* apply static CTLE tunings */ u8 pcie_dc, pcie_lf, pcie_hf, pcie_bw; - pcie_dc = ctle_tunings[pcie_pset][0 ]; - pcie_lf = ctle_tunings[pcie_pset][1 ]; - pcie_hf = ctle_tunings[pcie_pset][2 ]; - pcie_bw = ctle_tunings[pcie_pset][3 ]; + pcie_dc = ctle_tunings[pset][0 ]; + pcie_lf = ctle_tunings[pset][1 ]; + pcie_hf = ctle_tunings[pset][2 ]; + pcie_bw = ctle_tunings[pset][3 ];write_gasket_interrupt (dd, intnum++,0x0026 ,0x0200 | pcie_dc);write_gasket_interrupt (dd, intnum++,0x0026 ,0x0100 | pcie_lf);write_gasket_interrupt (dd, intnum++,0x0026 ,0x0000 | pcie_hf);
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/4 IB/hfi1: Convert PortXmitWait/PortVLXmitWait counters to flit times
In reply to a message not in the archiveFrom: Kamenee Arumugam <[email protected]>
HFI's counters SendWaitCnt and SendWaitVlCnt are in units of TXE cycle time (at 805MHz). OPA counters PortXmitWait and PortVLXmtWait are in units of flit times.
Convert the counter values to flit units using following conversion formula:
PortXmitWait =
SendWaitCnt * 2 * (4 /link_width) * (25 Gbps /link_speed) PortVLXmitWait = SendWaitVLCnt * 2 * (4 /link_width) * (25 Gbps /link_speed)
At link up or downgrade events, the link width can change. To ensure accurate counter calculations, sample the counters after the events, during counter requests, and then aggregate the OPA counters.
--- drivers/infiniband/hw/hfi1/chip.c | 64 +++++++++++++++++-- drivers/infiniband/hw/hfi1/chip.h | 4 + drivers/infiniband/hw/hfi1/hfi.h | 7 ++ drivers/infiniband/hw/hfi1/init.c | 9 +++ drivers/infiniband/hw/hfi1/mad.c | 127 ++++++++++++++++++++++++++++++++++--- drivers/infiniband/hw/hfi1/mad.h | 47 +++++++++++++- 6 files changed, 239 insertions(+), 19 deletions(-)
drivers/infiniband/hw/hfi1/chip.c +58 -6
@@ -1083,6 +1083,7 @@ static int qos_rmt_entries(struct hfi1_devdata *dd, unsigned int *mp,static void clear_full_mgmt_pkey (struct hfi1_pportdata *ppd);static int wait_link_transfer_active (struct hfi1_devdata *dd,int wait_ms);static void clear_rsm_rule (struct hfi1_devdata *dd,u8 rule_index); +static void update_xmit_counters (struct hfi1_pportdata *ppd,u16 link_width);/* * Error interrupt table entry. This is used as input to the interrupt
@@ -6905,6 +6906,32 @@ void handle_freeze(struct work_struct *work)/* no longer frozen */ } +/** +* update_xmit_counters - update PortXmitWait/PortVlXmitWait +* counters. +* @ppd: info of physical Hfi port +* @link_width: new link width after link up or downgrade +* +* Update the PortXmitWait and PortVlXmitWait counters after +* a link up or downgrade event to reflect a link width change. +*/ +static void update_xmit_counters (struct hfi1_pportdata *ppd,u16 link_width) +{ +int i; +u16 tx_width; +u16 link_speed; + + tx_width =tx_link_width (link_width); + link_speed =get_link_speed (ppd->link_speed_active); + +/* +* There are C_VL_COUNT number of PortVLXmitWait counters. +* Adding 1 to C_VL_COUNT to include the PortXmitWait counter. +*/ +for (i =0 ; i <C_VL_COUNT +1 ; i++) +get_xmit_wait_counters (ppd, tx_width, link_speed, i); +} +/* * Handle a link up interrupt from the 8051. *
@@ -7526,18 +7553,29 @@ void handle_verify_cap(struct work_struct *work)set_link_state (ppd,HLS_GOING_UP ); } -/* -* Apply the link width downgrade enabled policy against the current active -* link widths. +/** +* apply_link_downgrade_policy - Apply the link width downgrade enabled +* policy against the current active link widths. +* @ppd: info of physical Hfi port +* @refresh_widths: True indicates link downgrade event +* @return: True indicates a successful link downgrade. False indicates +* link downgrade event failed and the link will bounce back to +* default link width. * -* Called when the enabled policy changes or the active link widths change. +* Called when the enabled policy changes or the active link widths +* change. +* Refresh_widths indicates that a link downgrade occurred. The +* link_downgraded variable is set by refresh_widths and +* determines the success/failure of the policy application. */ -void apply_link_downgrade_policy (struct hfi1_pportdata *ppd,int refresh_widths) +bool apply_link_downgrade_policy (struct hfi1_pportdata *ppd, +bool refresh_widths) {int do_bounce =0 ;int tries;u16 lwde;u16 tx, rx; +bool link_downgraded = refresh_widths;/* use the hls lock to avoid a race with actual link up */ tries =0 ;
@@ -7571,6 +7609,7 @@ void apply_link_downgrade_policy(struct hfi1_pportdata *ppd, int refresh_widths) ppd->link_width_downgrade_rx_active == 0) {/* the 8051 reported a dead link as a downgrade */ dd_dev_err (ppd->dd,"Link downgrade is really a link down, ignoring\n" ); + link_downgraded = false; } else if (lwde == 0) {/* downgrade is disabled */
@@ -7587,6 +7626,7 @@ void apply_link_downgrade_policy(struct hfi1_pportdata *ppd, int refresh_widths) ppd->link_width_downgrade_tx_active, ppd->link_width_downgrade_rx_active); do_bounce =1 ; + link_downgraded = false; } }else if ((lwde & ppd->link_width_downgrade_tx_active) ==0 || (lwde & ppd->link_width_downgrade_rx_active) ==0 ) {
@@ -7598,6 +7638,7 @@ void apply_link_downgrade_policy(struct hfi1_pportdata *ppd, int refresh_widths) lwde, ppd->link_width_downgrade_tx_active, ppd->link_width_downgrade_rx_active); do_bounce =1 ; + link_downgraded = false; } done:
@@ -7609,6 +7650,8 @@ void apply_link_downgrade_policy(struct hfi1_pportdata *ppd, int refresh_widths)set_link_state (ppd,HLS_DN_OFFLINE );start_link (ppd); } + +return link_downgraded; }/*
@@ -7622,7 +7665,8 @@ void handle_link_downgrade(struct work_struct *work) link_downgrade_work);dd_dev_info (ppd->dd,"8051: Link width downgrade\n" ); -apply_link_downgrade_policy (ppd,1 ); +if (apply_link_downgrade_policy (ppd, true)) +update_xmit_counters (ppd, ppd->link_width_downgrade_tx_active); }static char *dcc_err_string (char *buf,int buf_len,u64 flags)
@@ -10597,6 +10641,14 @@ int set_link_state(struct hfi1_pportdata *ppd, u32 state)add_rcvctrl (dd,RCV_CTRL_RCV_PORT_ENABLE_SMASK );handle_linkup_change (dd,1 ); + +/* +* After link up, a new link width will have been set. +* Update the xmit counters with regards to the new +* link width. +*/ +update_xmit_counters (ppd, ppd->link_width_active); + ppd->host_link_state =HLS_UP_INIT ;update_statusp (ppd,IB_PORT_INIT );break ;
drivers/infiniband/hw/hfi1/chip.h +2 -2
@@ -736,8 +736,8 @@ void set_link_down_reason(struct hfi1_pportdata *ppd, u8 lcl_reason,int start_link (struct hfi1_pportdata *ppd);int bringup_serdes (struct hfi1_pportdata *ppd);void set_intr_state (struct hfi1_devdata *dd,u32 enable); -void apply_link_downgrade_policy (struct hfi1_pportdata *ppd, -int refresh_widths); +bool apply_link_downgrade_policy (struct hfi1_pportdata *ppd, +bool refresh_widths);void update_usrhead (struct hfi1_ctxtdata *rcd,u32 hd,u32 updegr,u32 egrhd,u32 intr_adjust,u32 npkts);int stop_drain_data_vls (struct hfi1_devdata *dd);
drivers/infiniband/hw/hfi1/hfi.h +7 -0
@@ -858,6 +858,13 @@ struct hfi1_pportdata {struct work_struct linkstate_active_work;/* Does this port need to prescan for FECNs */ bool cc_prescan; +/* +* Sample sendWaitCnt & sendWaitVlCnt during link transition +* and counter request. +*/ +u64 port_vl_xmit_wait_last[C_VL_COUNT +1 ]; +u16 prev_link_width; +u64 vl_xmit_flit_cnt[C_VL_COUNT +1 ]; };typedef int (*rhf_rcv_function_ptr )(struct hfi1_packet *packet);
drivers/infiniband/hw/hfi1/init.c +9 -0
@@ -637,6 +637,15 @@ void hfi1_init_pportdata(struct pci_dev *pdev, struct hfi1_pportdata *ppd, ppd->dd = dd; ppd->hw_pidx = hw_pidx; ppd->port = port;/* IB port number, not index */ + ppd->prev_link_width =LINK_WIDTH_DEFAULT ; +/* +* There are C_VL_COUNT number of PortVLXmitWait counters. +* Adding 1 to C_VL_COUNT to include the PortXmitWait counter. +*/ +for (i =0 ; i <C_VL_COUNT +1 ; i++) { + ppd->port_vl_xmit_wait_last[i] =0 ; + ppd->vl_xmit_flit_cnt[i] =0 ; + } default_pkey_idx =1 ;
drivers/infiniband/hw/hfi1/mad.c +117 -10
187 lines not on this page · raw message
drivers/infiniband/hw/hfi1/mad.h +46 -1
57 lines not on this page · raw message
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 3/4 IB/hfi1: Remove blind constants from 16B update
In reply to a message not in the archiveFrom: Mike Marciniszyn <[email protected]>
These values were introduced as part of the 16B code to account for the varying size of the LRH between the differing packet formats.
Replace the blind constants with defines based on FIELD_SIZEOF() calls.
--- drivers/infiniband/hw/hfi1/driver.c | 6 ++++-- drivers/infiniband/hw/hfi1/ruc.c | 13 ++++++------- drivers/infiniband/hw/hfi1/ud.c | 15 ++++++++++----- drivers/infiniband/hw/hfi1/verbs.h | 5 +++++ 4 files changed, 25 insertions(+), 14 deletions(-)
drivers/infiniband/hw/hfi1/driver.c +4 -2
@@ -1499,8 +1499,10 @@ static int hfi1_setup_bypass_packet(struct hfi1_packet *packet)/* Query commonly used fields from packet header */ packet->opcode =ib_bth_get_opcode (packet->ohdr); - packet->hlen = hdr_len_by_opcode[packet->opcode] +8 + grh_len; - packet->payload = packet->ebuf + packet->hlen - (4 *sizeof (u32)); +/* hdr_len_by_opcode already has an IB LRH factored in */ + packet->hlen = hdr_len_by_opcode[packet->opcode] + + (LRH_16B_BYTES -LRH_9B_BYTES ) + grh_len; + packet->payload = packet->ebuf + packet->hlen -LRH_16B_BYTES ; packet->slid =hfi1_16B_get_slid (packet->hdr); packet->dlid =hfi1_16B_get_dlid (packet->hdr);if (unlikely (hfi1_is_16B_mcast (packet->dlid)))
drivers/infiniband/hw/hfi1/ruc.c +6 -7
@@ -758,8 +758,6 @@ static inline void hfi1_make_ruc_header_16B(struct rvt_qp *qp,struct ib_grh *grh;struct ib_global_route *grd =rdma_ah_retrieve_grh (&qp->remote_ah_attr); -int hdrwords; -/* * Ensure OPA GIDs are transformed to IB gids * before creating the GRH.
@@ -768,9 +766,10 @@ static inline void hfi1_make_ruc_header_16B(struct rvt_qp *qp, grd->sgid_index =0 ; grh = &ps->s_txreq->phdr.hdr.opah.u.l.grh; l4 =OPA_16B_L4_IB_GLOBAL ; - hdrwords = ps->s_txreq->hdr_dwords -4 ; - ps->s_txreq->hdr_dwords +=hfi1_make_grh (ibp, grh, grd, - hdrwords, nwords); + ps->s_txreq->hdr_dwords += +hfi1_make_grh (ibp, grh, grd, + ps->s_txreq->hdr_dwords -LRH_16B_DWORDS , + nwords); middle =0 ; }
@@ -824,13 +823,13 @@ static inline void hfi1_make_ruc_header_9B(struct rvt_qp *qp,if (unlikely (rdma_ah_get_ah_flags (&qp->remote_ah_attr) &IB_AH_GRH )) {struct ib_grh *grh = &ps->s_txreq->phdr.hdr.ibh.u.l.grh; -int hdrwords = ps->s_txreq->hdr_dwords -2 ; lrh0 =HFI1_LRH_GRH ; ps->s_txreq->hdr_dwords +=hfi1_make_grh (ibp, grh,rdma_ah_read_grh (&qp->remote_ah_attr), - hdrwords, nwords); + ps->s_txreq->hdr_dwords -LRH_9B_DWORDS , + nwords); middle =0 ; } lrh0 |= (priv->s_sc & 0xf) << 12 |
drivers/infiniband/hw/hfi1/ud.c +10 -5
@@ -348,7 +348,8 @@ void hfi1_make_ud_req_9B(struct rvt_qp *qp, struct hfi1_pkt_state *ps, grh = &ps->s_txreq->phdr.hdr.ibh.u.l.grh; ps->s_txreq->hdr_dwords +=hfi1_make_grh (ibp, grh,rdma_ah_read_grh (ah_attr), - ps->s_txreq->hdr_dwords -2 , nwords); + ps->s_txreq->hdr_dwords -LRH_9B_DWORDS , + nwords); lrh0 =HFI1_LRH_GRH ; ohdr = &ps->s_txreq->phdr.hdr.ibh.u.l.oth; }else {
@@ -428,8 +429,10 @@ void hfi1_make_ud_req_16B(struct rvt_qp *qp, struct hfi1_pkt_state *ps, grd->sgid_index =0 ; } grh = &ps->s_txreq->phdr.hdr.opah.u.l.grh; - ps->s_txreq->hdr_dwords +=hfi1_make_grh (ibp, grh, grd, - ps->s_txreq->hdr_dwords -4 , nwords); + ps->s_txreq->hdr_dwords +=hfi1_make_grh ( + ibp, grh, grd, + ps->s_txreq->hdr_dwords -LRH_16B_DWORDS , + nwords); ohdr = &ps->s_txreq->phdr.hdr.opah.u.l.oth; l4 =OPA_16B_L4_IB_GLOBAL ; }else {
@@ -648,7 +651,8 @@ void return_cnp_16B(struct hfi1_ibport *ibp, struct rvt_qp *qp,struct ib_grh *grh = &hdr.u.l.grh; grh->version_tclass_flow = old_grh->version_tclass_flow; - grh->paylen =cpu_to_be16 ((hwords -4 + nwords) <<2 ); + grh->paylen =cpu_to_be16 ( + (hwords -LRH_16B_DWORDS + nwords) <<2 ); grh->hop_limit =0xff ; grh->sgid = old_grh->dgid; grh->dgid = old_grh->sgid;
@@ -702,7 +706,8 @@ void return_cnp(struct hfi1_ibport *ibp, struct rvt_qp *qp, u32 remote_qpn,struct ib_grh *grh = &hdr.u.l.grh; grh->version_tclass_flow = old_grh->version_tclass_flow; - grh->paylen =cpu_to_be16 ((hwords -2 +SIZE_OF_CRC ) <<2 ); + grh->paylen =cpu_to_be16 ( + (hwords -LRH_9B_DWORDS +SIZE_OF_CRC ) <<2 ); grh->hop_limit =0xff ; grh->sgid = old_grh->dgid; grh->dgid = old_grh->sgid;
drivers/infiniband/hw/hfi1/verbs.h +5 -0
@@ -105,6 +105,11 @@ enum { HFI1_HAS_GRH = (1 << 0), }; +#define LRH_16B_BYTES (FIELD_SIZEOF(struct hfi1_16b_header, lrh)) +#define LRH_16B_DWORDS (LRH_16B_BYTES / sizeof(u32)) +#define LRH_9B_BYTES (FIELD_SIZEOF(struct ib_header, lrh)) +#define LRH_9B_DWORDS (LRH_9B_BYTES / sizeof(u32)) +struct hfi1_16b_header {u32 lrh[4 ];union {
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 4/4 IB/hfi1: Show fault stats in both TX and RX directions
In reply to a message not in the archiveFrom: Mitko Haralanov <[email protected]>
The routine which shows the fault stats checks the counters to determine whether to show any stats based on the number of transmitted pkts/bytes for a particular opcode.
Unfortunately, it only checked the receive counters. As a result, if any packet faults have happened for packets egressing the HFI, those stats would not be shown.
In order to fix this, the routine is amended to also check the TX counters. With this change the pkt/byte counts are the sum of both TX and RX counts for the opcode.
--- drivers/infiniband/hw/hfi1/debugfs.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-)
drivers/infiniband/hw/hfi1/debugfs.c +8 -1
@@ -1,5 +1,5 @@/* -* Copyright(c) 2015-2017 Intel Corporation. +* Copyright(c) 2015-2018 Intel Corporation. * * This file is provided under a dual BSD/GPLv2 license. When using or * redistributing this file, you may do so under either license.
@@ -1201,6 +1201,13 @@ static int _fault_stats_seq_show(struct seq_file *s, void *v) }hfi1_rcd_put (rcd); } +for_each_possible_cpu (j) { +struct hfi1_opcode_stats_perctx *sp = +per_cpu_ptr (dd->tx_opstats, j); + + n_packets += sp->stats[i].n_packets; + n_bytes += sp->stats[i].n_bytes; + }if (!n_packets && !n_bytes)return SEQ_SKIP ; if (!ibd->fault_opcode->n_rxfaults[i] &&
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Jason Gunthorpe
AppliedQuoted 19 lines · Dennis Dalessandro
Hi Jason and Doug,
Here are some fixes for minor issues. Minor in terms of severity, not necessarily in terms of complexity. The diffstat for
mad.cin particular looks pretty bad but it's basically changing the units being used from cycle time to flit time.This is a resubmit of my previous patch set [1] broken up into smaller logically grouped patch sets.
As always my GitHub had these in-tree for context:
https://github.com/ddalessa/kernel/tree/for-4.16[1] https://www.spinics.net/lists/linux-rdma/msg60011.html
Bartlomiej Dudek (1):
IB/hfi1: Do not override givenpcie_psetvalue
Quoted 8 lines
Kamenee Arumugam (1):
IB/hfi1: Convert PortXmitWait/PortVLXmitWait counters to flit timesMike Marciniszyn (1):
IB/hfi1: Remove blind constants from 16B updateMitko Haralanov (1):
IB/hfi1: Show fault stats in both TX and RX directions
Applied to for-next, thanks,
Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html