aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
authorSelvin Xavier <selvin.xavier@emulex.com>2014-06-10 10:02:13 -0400
committerRoland Dreier <roland@purestorage.com>2014-08-01 18:07:36 -0400
commit31dbdd9af58c63c7f8376a0fa680f5fc1b6cce98 (patch)
treea6d096308dc817e9ce4194ba4aec804294de2185 /drivers/infiniband
parentf50f31e42fb772b62e209cf6ff5254b1bc02b756 (diff)
RDMA/ocrdma: Query and initalize the PFC SL
This patch implements routine to query the PFC priority from the adapter port. Following are the changes implemented: * A new FW command is implemented to query the operational/admin DCBX configuration from the FW and obtain active priority(service level). * Adds support for the async event reported by FW when the PFC priority changes. Service level is re-initialized during modify_qp or create_ah, based on this event. * Maintain SL value in ocrdma_dev structure and refer that as and when needed. Signed-off-by: Devesh Sharma <devesh.sharma@emulex.com> Signed-off-by: Selvin Xavier <selvin.xavier@emulex.com> Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r--drivers/infiniband/hw/ocrdma/ocrdma.h21
-rw-r--r--drivers/infiniband/hw/ocrdma/ocrdma_ah.c2
-rw-r--r--drivers/infiniband/hw/ocrdma/ocrdma_hw.c172
-rw-r--r--drivers/infiniband/hw/ocrdma/ocrdma_hw.h2
-rw-r--r--drivers/infiniband/hw/ocrdma/ocrdma_main.c1
-rw-r--r--drivers/infiniband/hw/ocrdma/ocrdma_sli.h81
6 files changed, 278 insertions, 1 deletions
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma.h b/drivers/infiniband/hw/ocrdma/ocrdma.h
index 19011dbb930f..5cd65c244191 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma.h
+++ b/drivers/infiniband/hw/ocrdma/ocrdma.h
@@ -236,6 +236,9 @@ struct ocrdma_dev {
236 struct rcu_head rcu; 236 struct rcu_head rcu;
237 int id; 237 int id;
238 u64 stag_arr[OCRDMA_MAX_STAG]; 238 u64 stag_arr[OCRDMA_MAX_STAG];
239 u8 sl; /* service level */
240 bool pfc_state;
241 atomic_t update_sl;
239 u16 pvid; 242 u16 pvid;
240 u32 asic_id; 243 u32 asic_id;
241 244
@@ -518,4 +521,22 @@ static inline u8 ocrdma_get_asic_type(struct ocrdma_dev *dev)
518 OCRDMA_SLI_ASIC_GEN_NUM_SHIFT; 521 OCRDMA_SLI_ASIC_GEN_NUM_SHIFT;
519} 522}
520 523
524static inline u8 ocrdma_get_pfc_prio(u8 *pfc, u8 prio)
525{
526 return *(pfc + prio);
527}
528
529static inline u8 ocrdma_get_app_prio(u8 *app_prio, u8 prio)
530{
531 return *(app_prio + prio);
532}
533
534static inline u8 ocrdma_is_enabled_and_synced(u32 state)
535{ /* May also be used to interpret TC-state, QCN-state
536 * Appl-state and Logical-link-state in future.
537 */
538 return (state & OCRDMA_STATE_FLAG_ENABLED) &&
539 (state & OCRDMA_STATE_FLAG_SYNC);
540}
541
521#endif 542#endif
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_ah.c b/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
index d4cc01f10c01..a023234d4b92 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
@@ -100,6 +100,8 @@ struct ib_ah *ocrdma_create_ah(struct ib_pd *ibpd, struct ib_ah_attr *attr)
100 if (!(attr->ah_flags & IB_AH_GRH)) 100 if (!(attr->ah_flags & IB_AH_GRH))
101 return ERR_PTR(-EINVAL); 101 return ERR_PTR(-EINVAL);
102 102
103 if (atomic_cmpxchg(&dev->update_sl, 1, 0))
104 ocrdma_init_service_level(dev);
103 ah = kzalloc(sizeof(*ah), GFP_ATOMIC); 105 ah = kzalloc(sizeof(*ah), GFP_ATOMIC);
104 if (!ah) 106 if (!ah)
105 return ERR_PTR(-ENOMEM); 107 return ERR_PTR(-ENOMEM);
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
index bce4adf342ce..e6463cb0f988 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
@@ -771,6 +771,10 @@ static void ocrdma_process_grp5_aync(struct ocrdma_dev *dev,
771 OCRDMA_AE_PVID_MCQE_TAG_MASK) >> 771 OCRDMA_AE_PVID_MCQE_TAG_MASK) >>
772 OCRDMA_AE_PVID_MCQE_TAG_SHIFT); 772 OCRDMA_AE_PVID_MCQE_TAG_SHIFT);
773 break; 773 break;
774
775 case OCRDMA_ASYNC_EVENT_COS_VALUE:
776 atomic_set(&dev->update_sl, 1);
777 break;
774 default: 778 default:
775 /* Not interested evts. */ 779 /* Not interested evts. */
776 break; 780 break;
@@ -2265,6 +2269,8 @@ static int ocrdma_set_av_params(struct ocrdma_qp *qp,
2265 2269
2266 if ((ah_attr->ah_flags & IB_AH_GRH) == 0) 2270 if ((ah_attr->ah_flags & IB_AH_GRH) == 0)
2267 return -EINVAL; 2271 return -EINVAL;
2272 if (atomic_cmpxchg(&qp->dev->update_sl, 1, 0))
2273 ocrdma_init_service_level(qp->dev);
2268 cmd->params.tclass_sq_psn |= 2274 cmd->params.tclass_sq_psn |=
2269 (ah_attr->grh.traffic_class << OCRDMA_QP_PARAMS_TCLASS_SHIFT); 2275 (ah_attr->grh.traffic_class << OCRDMA_QP_PARAMS_TCLASS_SHIFT);
2270 cmd->params.rnt_rc_sl_fl |= 2276 cmd->params.rnt_rc_sl_fl |=
@@ -2298,6 +2304,10 @@ static int ocrdma_set_av_params(struct ocrdma_qp *qp,
2298 cmd->params.vlan_dmac_b4_to_b5 |= 2304 cmd->params.vlan_dmac_b4_to_b5 |=
2299 vlan_id << OCRDMA_QP_PARAMS_VLAN_SHIFT; 2305 vlan_id << OCRDMA_QP_PARAMS_VLAN_SHIFT;
2300 cmd->flags |= OCRDMA_QP_PARA_VLAN_EN_VALID; 2306 cmd->flags |= OCRDMA_QP_PARA_VLAN_EN_VALID;
2307 /* override the sl with default priority if 0 */
2308 cmd->params.rnt_rc_sl_fl |=
2309 (ah_attr->sl ? ah_attr->sl :
2310 qp->dev->sl) << OCRDMA_QP_PARAMS_SL_SHIFT;
2301 } 2311 }
2302 return 0; 2312 return 0;
2303} 2313}
@@ -2605,6 +2615,168 @@ int ocrdma_mbx_destroy_srq(struct ocrdma_dev *dev, struct ocrdma_srq *srq)
2605 return status; 2615 return status;
2606} 2616}
2607 2617
2618static int ocrdma_mbx_get_dcbx_config(struct ocrdma_dev *dev, u32 ptype,
2619 struct ocrdma_dcbx_cfg *dcbxcfg)
2620{
2621 int status = 0;
2622 dma_addr_t pa;
2623 struct ocrdma_mqe cmd;
2624
2625 struct ocrdma_get_dcbx_cfg_req *req = NULL;
2626 struct ocrdma_get_dcbx_cfg_rsp *rsp = NULL;
2627 struct pci_dev *pdev = dev->nic_info.pdev;
2628 struct ocrdma_mqe_sge *mqe_sge = cmd.u.nonemb_req.sge;
2629
2630 memset(&cmd, 0, sizeof(struct ocrdma_mqe));
2631 cmd.hdr.pyld_len = max_t (u32, sizeof(struct ocrdma_get_dcbx_cfg_rsp),
2632 sizeof(struct ocrdma_get_dcbx_cfg_req));
2633 req = dma_alloc_coherent(&pdev->dev, cmd.hdr.pyld_len, &pa, GFP_KERNEL);
2634 if (!req) {
2635 status = -ENOMEM;
2636 goto mem_err;
2637 }
2638
2639 cmd.hdr.spcl_sge_cnt_emb |= (1 << OCRDMA_MQE_HDR_SGE_CNT_SHIFT) &
2640 OCRDMA_MQE_HDR_SGE_CNT_MASK;
2641 mqe_sge->pa_lo = (u32) (pa & 0xFFFFFFFFUL);
2642 mqe_sge->pa_hi = (u32) upper_32_bits(pa);
2643 mqe_sge->len = cmd.hdr.pyld_len;
2644
2645 memset(req, 0, sizeof(struct ocrdma_get_dcbx_cfg_req));
2646 ocrdma_init_mch(&req->hdr, OCRDMA_CMD_GET_DCBX_CONFIG,
2647 OCRDMA_SUBSYS_DCBX, cmd.hdr.pyld_len);
2648 req->param_type = ptype;
2649
2650 status = ocrdma_mbx_cmd(dev, &cmd);
2651 if (status)
2652 goto mbx_err;
2653
2654 rsp = (struct ocrdma_get_dcbx_cfg_rsp *)req;
2655 ocrdma_le32_to_cpu(rsp, sizeof(struct ocrdma_get_dcbx_cfg_rsp));
2656 memcpy(dcbxcfg, &rsp->cfg, sizeof(struct ocrdma_dcbx_cfg));
2657
2658mbx_err:
2659 dma_free_coherent(&pdev->dev, cmd.hdr.pyld_len, req, pa);
2660mem_err:
2661 return status;
2662}
2663
2664#define OCRDMA_MAX_SERVICE_LEVEL_INDEX 0x08
2665#define OCRDMA_DEFAULT_SERVICE_LEVEL 0x05
2666
2667static int ocrdma_parse_dcbxcfg_rsp(struct ocrdma_dev *dev, int ptype,
2668 struct ocrdma_dcbx_cfg *dcbxcfg,
2669 u8 *srvc_lvl)
2670{
2671 int status = -EINVAL, indx, slindx;
2672 int ventry_cnt;
2673 struct ocrdma_app_parameter *app_param;
2674 u8 valid, proto_sel;
2675 u8 app_prio, pfc_prio;
2676 u16 proto;
2677
2678 if (!(dcbxcfg->tcv_aev_opv_st & OCRDMA_DCBX_STATE_MASK)) {
2679 pr_info("%s ocrdma%d DCBX is disabled\n",
2680 dev_name(&dev->nic_info.pdev->dev), dev->id);
2681 goto out;
2682 }
2683
2684 if (!ocrdma_is_enabled_and_synced(dcbxcfg->pfc_state)) {
2685 pr_info("%s ocrdma%d priority flow control(%s) is %s%s\n",
2686 dev_name(&dev->nic_info.pdev->dev), dev->id,
2687 (ptype > 0 ? "operational" : "admin"),
2688 (dcbxcfg->pfc_state & OCRDMA_STATE_FLAG_ENABLED) ?
2689 "enabled" : "disabled",
2690 (dcbxcfg->pfc_state & OCRDMA_STATE_FLAG_SYNC) ?
2691 "" : ", not sync'ed");
2692 goto out;
2693 } else {
2694 pr_info("%s ocrdma%d priority flow control is enabled and sync'ed\n",
2695 dev_name(&dev->nic_info.pdev->dev), dev->id);
2696 }
2697
2698 ventry_cnt = (dcbxcfg->tcv_aev_opv_st >>
2699 OCRDMA_DCBX_APP_ENTRY_SHIFT)
2700 & OCRDMA_DCBX_STATE_MASK;
2701
2702 for (indx = 0; indx < ventry_cnt; indx++) {
2703 app_param = &dcbxcfg->app_param[indx];
2704 valid = (app_param->valid_proto_app >>
2705 OCRDMA_APP_PARAM_VALID_SHIFT)
2706 & OCRDMA_APP_PARAM_VALID_MASK;
2707 proto_sel = (app_param->valid_proto_app
2708 >> OCRDMA_APP_PARAM_PROTO_SEL_SHIFT)
2709 & OCRDMA_APP_PARAM_PROTO_SEL_MASK;
2710 proto = app_param->valid_proto_app &
2711 OCRDMA_APP_PARAM_APP_PROTO_MASK;
2712
2713 if (
2714 valid && proto == OCRDMA_APP_PROTO_ROCE &&
2715 proto_sel == OCRDMA_PROTO_SELECT_L2) {
2716 for (slindx = 0; slindx <
2717 OCRDMA_MAX_SERVICE_LEVEL_INDEX; slindx++) {
2718 app_prio = ocrdma_get_app_prio(
2719 (u8 *)app_param->app_prio,
2720 slindx);
2721 pfc_prio = ocrdma_get_pfc_prio(
2722 (u8 *)dcbxcfg->pfc_prio,
2723 slindx);
2724
2725 if (app_prio && pfc_prio) {
2726 *srvc_lvl = slindx;
2727 status = 0;
2728 goto out;
2729 }
2730 }
2731 if (slindx == OCRDMA_MAX_SERVICE_LEVEL_INDEX) {
2732 pr_info("%s ocrdma%d application priority not set for 0x%x protocol\n",
2733 dev_name(&dev->nic_info.pdev->dev),
2734 dev->id, proto);
2735 }
2736 }
2737 }
2738
2739out:
2740 return status;
2741}
2742
2743void ocrdma_init_service_level(struct ocrdma_dev *dev)
2744{
2745 int status = 0, indx;
2746 struct ocrdma_dcbx_cfg dcbxcfg;
2747 u8 srvc_lvl = OCRDMA_DEFAULT_SERVICE_LEVEL;
2748 int ptype = OCRDMA_PARAMETER_TYPE_OPER;
2749
2750 for (indx = 0; indx < 2; indx++) {
2751 status = ocrdma_mbx_get_dcbx_config(dev, ptype, &dcbxcfg);
2752 if (status) {
2753 pr_err("%s(): status=%d\n", __func__, status);
2754 ptype = OCRDMA_PARAMETER_TYPE_ADMIN;
2755 continue;
2756 }
2757
2758 status = ocrdma_parse_dcbxcfg_rsp(dev, ptype,
2759 &dcbxcfg, &srvc_lvl);
2760 if (status) {
2761 ptype = OCRDMA_PARAMETER_TYPE_ADMIN;
2762 continue;
2763 }
2764
2765 break;
2766 }
2767
2768 if (status)
2769 pr_info("%s ocrdma%d service level default\n",
2770 dev_name(&dev->nic_info.pdev->dev), dev->id);
2771 else
2772 pr_info("%s ocrdma%d service level %d\n",
2773 dev_name(&dev->nic_info.pdev->dev), dev->id,
2774 srvc_lvl);
2775
2776 dev->pfc_state = ocrdma_is_enabled_and_synced(dcbxcfg.pfc_state);
2777 dev->sl = srvc_lvl;
2778}
2779
2608int ocrdma_alloc_av(struct ocrdma_dev *dev, struct ocrdma_ah *ah) 2780int ocrdma_alloc_av(struct ocrdma_dev *dev, struct ocrdma_ah *ah)
2609{ 2781{
2610 int i; 2782 int i;
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_hw.h b/drivers/infiniband/hw/ocrdma/ocrdma_hw.h
index e513f7293142..6eed8f191322 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_hw.h
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_hw.h
@@ -135,4 +135,6 @@ int ocrdma_get_irq(struct ocrdma_dev *dev, struct ocrdma_eq *eq);
135 135
136int ocrdma_mbx_rdma_stats(struct ocrdma_dev *, bool reset); 136int ocrdma_mbx_rdma_stats(struct ocrdma_dev *, bool reset);
137char *port_speed_string(struct ocrdma_dev *dev); 137char *port_speed_string(struct ocrdma_dev *dev);
138void ocrdma_init_service_level(struct ocrdma_dev *);
139
138#endif /* __OCRDMA_HW_H__ */ 140#endif /* __OCRDMA_HW_H__ */
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_main.c b/drivers/infiniband/hw/ocrdma/ocrdma_main.c
index 7c504e079744..9368d52888bb 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_main.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_main.c
@@ -399,6 +399,7 @@ static struct ocrdma_dev *ocrdma_add(struct be_dev_info *dev_info)
399 if (status) 399 if (status)
400 goto alloc_err; 400 goto alloc_err;
401 401
402 ocrdma_init_service_level(dev);
402 status = ocrdma_register_device(dev); 403 status = ocrdma_register_device(dev);
403 if (status) 404 if (status)
404 goto alloc_err; 405 goto alloc_err;
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_sli.h b/drivers/infiniband/hw/ocrdma/ocrdma_sli.h
index 96c9ee602ba4..4defae8f63df 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_sli.h
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_sli.h
@@ -422,7 +422,12 @@ struct ocrdma_ae_qp_mcqe {
422 422
423#define OCRDMA_ASYNC_RDMA_EVE_CODE 0x14 423#define OCRDMA_ASYNC_RDMA_EVE_CODE 0x14
424#define OCRDMA_ASYNC_GRP5_EVE_CODE 0x5 424#define OCRDMA_ASYNC_GRP5_EVE_CODE 0x5
425#define OCRDMA_ASYNC_EVENT_PVID_STATE 0x3 425
426enum ocrdma_async_grp5_events {
427 OCRDMA_ASYNC_EVENT_QOS_VALUE = 0x01,
428 OCRDMA_ASYNC_EVENT_COS_VALUE = 0x02,
429 OCRDMA_ASYNC_EVENT_PVID_STATE = 0x03
430};
426 431
427enum OCRDMA_ASYNC_EVENT_TYPE { 432enum OCRDMA_ASYNC_EVENT_TYPE {
428 OCRDMA_CQ_ERROR = 0x00, 433 OCRDMA_CQ_ERROR = 0x00,
@@ -1949,5 +1954,79 @@ struct ocrdma_get_ctrl_attribs_rsp {
1949 struct mgmt_controller_attrib ctrl_attribs; 1954 struct mgmt_controller_attrib ctrl_attribs;
1950}; 1955};
1951 1956
1957#define OCRDMA_SUBSYS_DCBX 0x10
1958
1959enum OCRDMA_DCBX_OPCODE {
1960 OCRDMA_CMD_GET_DCBX_CONFIG = 0x01
1961};
1962
1963enum OCRDMA_DCBX_PARAM_TYPE {
1964 OCRDMA_PARAMETER_TYPE_ADMIN = 0x00,
1965 OCRDMA_PARAMETER_TYPE_OPER = 0x01,
1966 OCRDMA_PARAMETER_TYPE_PEER = 0x02
1967};
1968
1969enum OCRDMA_DCBX_APP_PROTO {
1970 OCRDMA_APP_PROTO_ROCE = 0x8915
1971};
1972
1973enum OCRDMA_DCBX_PROTO {
1974 OCRDMA_PROTO_SELECT_L2 = 0x00,
1975 OCRDMA_PROTO_SELECT_L4 = 0x01
1976};
1977
1978enum OCRDMA_DCBX_APP_PARAM {
1979 OCRDMA_APP_PARAM_APP_PROTO_MASK = 0xFFFF,
1980 OCRDMA_APP_PARAM_PROTO_SEL_MASK = 0xFF,
1981 OCRDMA_APP_PARAM_PROTO_SEL_SHIFT = 0x10,
1982 OCRDMA_APP_PARAM_VALID_MASK = 0xFF,
1983 OCRDMA_APP_PARAM_VALID_SHIFT = 0x18
1984};
1985
1986enum OCRDMA_DCBX_STATE_FLAGS {
1987 OCRDMA_STATE_FLAG_ENABLED = 0x01,
1988 OCRDMA_STATE_FLAG_ADDVERTISED = 0x02,
1989 OCRDMA_STATE_FLAG_WILLING = 0x04,
1990 OCRDMA_STATE_FLAG_SYNC = 0x08,
1991 OCRDMA_STATE_FLAG_UNSUPPORTED = 0x40000000,
1992 OCRDMA_STATE_FLAG_NEG_FAILD = 0x80000000
1993};
1994
1995enum OCRDMA_TCV_AEV_OPV_ST {
1996 OCRDMA_DCBX_TC_SUPPORT_MASK = 0xFF,
1997 OCRDMA_DCBX_TC_SUPPORT_SHIFT = 0x18,
1998 OCRDMA_DCBX_APP_ENTRY_SHIFT = 0x10,
1999 OCRDMA_DCBX_OP_PARAM_SHIFT = 0x08,
2000 OCRDMA_DCBX_STATE_MASK = 0xFF
2001};
2002
2003struct ocrdma_app_parameter {
2004 u32 valid_proto_app;
2005 u32 oui;
2006 u32 app_prio[2];
2007};
2008
2009struct ocrdma_dcbx_cfg {
2010 u32 tcv_aev_opv_st;
2011 u32 tc_state;
2012 u32 pfc_state;
2013 u32 qcn_state;
2014 u32 appl_state;
2015 u32 ll_state;
2016 u32 tc_bw[2];
2017 u32 tc_prio[8];
2018 u32 pfc_prio[2];
2019 struct ocrdma_app_parameter app_param[15];
2020};
2021
2022struct ocrdma_get_dcbx_cfg_req {
2023 struct ocrdma_mbx_hdr hdr;
2024 u32 param_type;
2025} __packed;
2026
2027struct ocrdma_get_dcbx_cfg_rsp {
2028 struct ocrdma_mbx_rsp hdr;
2029 struct ocrdma_dcbx_cfg cfg;
2030} __packed;
1952 2031
1953#endif /* __OCRDMA_SLI_H__ */ 2032#endif /* __OCRDMA_SLI_H__ */