Lines Matching full:dcb

36 	struct port_dcb_info *dcb = &pi->dcb;  in cxgb4_dcb_state_init()  local
37 int version_temp = dcb->dcb_version; in cxgb4_dcb_state_init()
39 memset(dcb, 0, sizeof(struct port_dcb_info)); in cxgb4_dcb_state_init()
40 dcb->state = CXGB4_DCB_STATE_START; in cxgb4_dcb_state_init()
42 dcb->dcb_version = version_temp; in cxgb4_dcb_state_init()
44 netdev_dbg(dev, "%s: Initializing DCB state for port[%d]\n", in cxgb4_dcb_state_init()
51 struct port_dcb_info *dcb = &pi->dcb; in cxgb4_dcb_version_init() local
56 dcb->dcb_version = FW_PORT_DCB_VER_AUTO; in cxgb4_dcb_version_init()
63 struct port_dcb_info *dcb = &pi->dcb; in cxgb4_dcb_cleanup_apps() local
72 if (!dcb->app_priority[i].protocolid) in cxgb4_dcb_cleanup_apps()
75 app.protocol = dcb->app_priority[i].protocolid; in cxgb4_dcb_cleanup_apps()
77 if (dcb->dcb_version == FW_PORT_DCB_VER_IEEE) { in cxgb4_dcb_cleanup_apps()
78 app.priority = dcb->app_priority[i].user_prio_map; in cxgb4_dcb_cleanup_apps()
79 app.selector = dcb->app_priority[i].sel_field + 1; in cxgb4_dcb_cleanup_apps()
82 app.selector = !!(dcb->app_priority[i].sel_field); in cxgb4_dcb_cleanup_apps()
88 "Failed DCB Clear %s Application Priority: sel=%d, prot=%d, err=%d\n", in cxgb4_dcb_cleanup_apps()
89 dcb_ver_array[dcb->dcb_version], app.selector, in cxgb4_dcb_cleanup_apps()
105 /* update the dcb port support, if version is IEEE then set it to
107 * clear that. and if it is set to CEE then set dcb supported to
110 static inline void cxgb4_dcb_update_support(struct port_dcb_info *dcb) in cxgb4_dcb_update_support() argument
112 if (dcb->dcb_version == FW_PORT_DCB_VER_IEEE) { in cxgb4_dcb_update_support()
113 if (dcb->supported & DCB_CAP_DCBX_VER_CEE) in cxgb4_dcb_update_support()
114 dcb->supported &= ~DCB_CAP_DCBX_VER_CEE; in cxgb4_dcb_update_support()
115 dcb->supported |= DCB_CAP_DCBX_VER_IEEE; in cxgb4_dcb_update_support()
116 } else if (dcb->dcb_version == FW_PORT_DCB_VER_CEE1D01) { in cxgb4_dcb_update_support()
117 if (dcb->supported & DCB_CAP_DCBX_VER_IEEE) in cxgb4_dcb_update_support()
118 dcb->supported &= ~DCB_CAP_DCBX_VER_IEEE; in cxgb4_dcb_update_support()
119 dcb->supported |= DCB_CAP_DCBX_VER_CEE; in cxgb4_dcb_update_support()
129 struct port_dcb_info *dcb = &pi->dcb; in cxgb4_dcb_state_fsm() local
131 enum cxgb4_dcb_state current_state = dcb->state; in cxgb4_dcb_state_fsm()
134 __func__, dcb->state, transition_to, dev->name); in cxgb4_dcb_state_fsm()
140 /* we're going to use Host DCB */ in cxgb4_dcb_state_fsm()
141 dcb->state = CXGB4_DCB_STATE_HOST; in cxgb4_dcb_state_fsm()
142 dcb->supported = CXGB4_DCBX_HOST_SUPPORT; in cxgb4_dcb_state_fsm()
147 /* we're going to use Firmware DCB */ in cxgb4_dcb_state_fsm()
148 dcb->state = CXGB4_DCB_STATE_FW_INCOMPLETE; in cxgb4_dcb_state_fsm()
149 dcb->supported = DCB_CAP_DCBX_LLD_MANAGED; in cxgb4_dcb_state_fsm()
150 if (dcb->dcb_version == FW_PORT_DCB_VER_IEEE) in cxgb4_dcb_state_fsm()
151 dcb->supported |= DCB_CAP_DCBX_VER_IEEE; in cxgb4_dcb_state_fsm()
153 dcb->supported |= DCB_CAP_DCBX_VER_CEE; in cxgb4_dcb_state_fsm()
163 dcb->state = CXGB4_DCB_STATE_FW_ALLSYNCED; in cxgb4_dcb_state_fsm()
176 * check if the dcb version is changed (there can be in cxgb4_dcb_state_fsm()
178 * configuration at FW, so update the dcb support in cxgb4_dcb_state_fsm()
181 cxgb4_dcb_update_support(dcb); in cxgb4_dcb_state_fsm()
185 /* we're alreaady in firmware DCB mode */ in cxgb4_dcb_state_fsm()
195 dcb->state = CXGB4_DCB_STATE_FW_ALLSYNCED; in cxgb4_dcb_state_fsm()
196 dcb->enabled = 1; in cxgb4_dcb_state_fsm()
210 /* we're alreaady in firmware DCB mode */ in cxgb4_dcb_state_fsm()
215 /* We were successfully running with firmware DCB but in cxgb4_dcb_state_fsm()
221 dcb->state = CXGB4_DCB_STATE_FW_INCOMPLETE; in cxgb4_dcb_state_fsm()
222 dcb->supported = CXGB4_DCBX_FW_SUPPORT; in cxgb4_dcb_state_fsm()
232 dcb->enabled = 1; in cxgb4_dcb_state_fsm()
246 /* we're alreaady in Host DCB mode */ in cxgb4_dcb_state_fsm()
271 /* Handle a DCB/DCBX update message from the firmware.
276 const union fw_port_dcb *fwdcb = &pcmd->u.dcb; in cxgb4_dcb_handle_fw_update()
280 struct port_dcb_info *dcb = &pi->dcb; in cxgb4_dcb_handle_fw_update() local
281 int dcb_type = pcmd->u.dcb.pgid.type; in cxgb4_dcb_handle_fw_update()
284 /* Handle Firmware DCB Control messages separately since they drive in cxgb4_dcb_handle_fw_update()
289 ((pcmd->u.dcb.control.all_syncd_pkd & in cxgb4_dcb_handle_fw_update()
294 if (dcb->dcb_version != FW_PORT_DCB_VER_UNKNOWN) { in cxgb4_dcb_handle_fw_update()
297 pcmd->u.dcb.control.dcb_version_to_app_state)); in cxgb4_dcb_handle_fw_update()
300 dcb->dcb_version = dcb_running_version; in cxgb4_dcb_handle_fw_update()
303 dcb_ver_array[dcb->dcb_version]); in cxgb4_dcb_handle_fw_update()
307 dcb_ver_array[dcb->dcb_version], in cxgb4_dcb_handle_fw_update()
309 dcb->dcb_version = FW_PORT_DCB_VER_UNKNOWN; in cxgb4_dcb_handle_fw_update()
317 /* It's weird, and almost certainly an error, to get Firmware DCB in cxgb4_dcb_handle_fw_update()
319 * doing Host or Firmware DCB; and even worse when we've been told in cxgb4_dcb_handle_fw_update()
320 * that we're doing Host DCB! in cxgb4_dcb_handle_fw_update()
322 if (dcb->state == CXGB4_DCB_STATE_START || in cxgb4_dcb_handle_fw_update()
323 dcb->state == CXGB4_DCB_STATE_HOST) { in cxgb4_dcb_handle_fw_update()
324 dev_err(adap->pdev_dev, "Receiving Firmware DCB messages in State %d\n", in cxgb4_dcb_handle_fw_update()
325 dcb->state); in cxgb4_dcb_handle_fw_update()
329 /* Now handle the general Firmware DCB update messages ... in cxgb4_dcb_handle_fw_update()
333 dcb->pgid = be32_to_cpu(fwdcb->pgid.pgid); in cxgb4_dcb_handle_fw_update()
334 dcb->msgs |= CXGB4_DCB_FW_PGID; in cxgb4_dcb_handle_fw_update()
338 dcb->pg_num_tcs_supported = fwdcb->pgrate.num_tcs_supported; in cxgb4_dcb_handle_fw_update()
339 memcpy(dcb->pgrate, &fwdcb->pgrate.pgrate, in cxgb4_dcb_handle_fw_update()
340 sizeof(dcb->pgrate)); in cxgb4_dcb_handle_fw_update()
341 memcpy(dcb->tsa, &fwdcb->pgrate.tsa, in cxgb4_dcb_handle_fw_update()
342 sizeof(dcb->tsa)); in cxgb4_dcb_handle_fw_update()
343 dcb->msgs |= CXGB4_DCB_FW_PGRATE; in cxgb4_dcb_handle_fw_update()
344 if (dcb->msgs & CXGB4_DCB_FW_PGID) in cxgb4_dcb_handle_fw_update()
345 IEEE_FAUX_SYNC(dev, dcb); in cxgb4_dcb_handle_fw_update()
349 memcpy(dcb->priorate, &fwdcb->priorate.strict_priorate, in cxgb4_dcb_handle_fw_update()
350 sizeof(dcb->priorate)); in cxgb4_dcb_handle_fw_update()
351 dcb->msgs |= CXGB4_DCB_FW_PRIORATE; in cxgb4_dcb_handle_fw_update()
355 dcb->pfcen = fwdcb->pfc.pfcen; in cxgb4_dcb_handle_fw_update()
356 dcb->pfc_num_tcs_supported = fwdcb->pfc.max_pfc_tcs; in cxgb4_dcb_handle_fw_update()
357 dcb->msgs |= CXGB4_DCB_FW_PFC; in cxgb4_dcb_handle_fw_update()
358 IEEE_FAUX_SYNC(dev, dcb); in cxgb4_dcb_handle_fw_update()
364 struct app_priority *ap = &dcb->app_priority[idx]; in cxgb4_dcb_handle_fw_update()
374 if (dcb->dcb_version == FW_PORT_DCB_VER_IEEE) { in cxgb4_dcb_handle_fw_update()
378 IEEE_FAUX_SYNC(dev, dcb); in cxgb4_dcb_handle_fw_update()
388 "Failed DCB Set Application Priority: sel=%d, prot=%d, prio=%d, err=%d\n", in cxgb4_dcb_handle_fw_update()
394 dcb->msgs |= CXGB4_DCB_FW_APP_ID; in cxgb4_dcb_handle_fw_update()
399 dev_err(adap->pdev_dev, "Unknown DCB update type received %x\n", in cxgb4_dcb_handle_fw_update()
409 /* Get current DCB enabled/disabled state.
415 return pi->dcb.enabled; in cxgb4_getstate()
418 /* Set DCB enabled/disabled.
424 /* If DCBx is host-managed, dcb is enabled by outside lldp agents */ in cxgb4_setstate()
425 if (pi->dcb.state == CXGB4_DCB_STATE_HOST) { in cxgb4_setstate()
426 pi->dcb.enabled = enabled; in cxgb4_setstate()
430 /* Firmware doesn't provide any mechanism to control the DCB state. in cxgb4_setstate()
432 if (enabled != (pi->dcb.state == CXGB4_DCB_STATE_FW_ALLSYNCED)) in cxgb4_setstate()
454 pcmd.u.dcb.pgid.type = FW_PORT_DCB_TYPE_PGID; in cxgb4_getpgtccfg()
457 dev_err(adap->pdev_dev, "DCB read PGID failed with %d\n", -err); in cxgb4_getpgtccfg()
460 *pgid = (be32_to_cpu(pcmd.u.dcb.pgid.pgid) >> (tc * 4)) & 0xf; in cxgb4_getpgtccfg()
466 pcmd.u.dcb.pgrate.type = FW_PORT_DCB_TYPE_PGRATE; in cxgb4_getpgtccfg()
469 dev_err(adap->pdev_dev, "DCB read PGRATE failed with %d\n", in cxgb4_getpgtccfg()
474 *bw_per = pcmd.u.dcb.pgrate.pgrate[*pgid]; in cxgb4_getpgtccfg()
518 pcmd.u.dcb.pgid.type = FW_PORT_DCB_TYPE_PGID; in cxgb4_setpgtccfg_tx()
522 dev_err(adap->pdev_dev, "DCB read PGID failed with %d\n", -err); in cxgb4_setpgtccfg_tx()
526 _pgid = be32_to_cpu(pcmd.u.dcb.pgid.pgid); in cxgb4_setpgtccfg_tx()
529 pcmd.u.dcb.pgid.pgid = cpu_to_be32(_pgid); in cxgb4_setpgtccfg_tx()
535 dev_err(adap->pdev_dev, "DCB write PGID failed with %d\n", in cxgb4_setpgtccfg_tx()
543 pcmd.u.dcb.pgrate.type = FW_PORT_DCB_TYPE_PGRATE; in cxgb4_setpgtccfg_tx()
547 dev_err(adap->pdev_dev, "DCB read PGRATE failed with %d\n", in cxgb4_setpgtccfg_tx()
552 pcmd.u.dcb.pgrate.pgrate[pgid] = bw_per; in cxgb4_setpgtccfg_tx()
555 if (pi->dcb.state == CXGB4_DCB_STATE_HOST) in cxgb4_setpgtccfg_tx()
560 dev_err(adap->pdev_dev, "DCB write PGRATE failed with %d\n", in cxgb4_setpgtccfg_tx()
577 pcmd.u.dcb.pgrate.type = FW_PORT_DCB_TYPE_PGRATE; in cxgb4_getpgbwgcfg()
580 dev_err(adap->pdev_dev, "DCB read PGRATE failed with %d\n", in cxgb4_getpgbwgcfg()
585 *bw_per = pcmd.u.dcb.pgrate.pgrate[pgid]; in cxgb4_getpgbwgcfg()
607 pcmd.u.dcb.pgrate.type = FW_PORT_DCB_TYPE_PGRATE; in cxgb4_setpgbwgcfg_tx()
611 dev_err(adap->pdev_dev, "DCB read PGRATE failed with %d\n", in cxgb4_setpgbwgcfg_tx()
616 pcmd.u.dcb.pgrate.pgrate[pgid] = bw_per; in cxgb4_setpgbwgcfg_tx()
619 if (pi->dcb.state == CXGB4_DCB_STATE_HOST) in cxgb4_setpgbwgcfg_tx()
625 dev_err(adap->pdev_dev, "DCB write PGRATE failed with %d\n", in cxgb4_setpgbwgcfg_tx()
635 struct port_dcb_info *dcb = &pi->dcb; in cxgb4_getpfccfg() local
637 if (!cxgb4_dcb_state_synced(dcb->state) || in cxgb4_getpfccfg()
641 *pfccfg = (pi->dcb.pfcen >> (7 - priority)) & 1; in cxgb4_getpfccfg()
654 if (!cxgb4_dcb_state_synced(pi->dcb.state) || in cxgb4_setpfccfg()
659 if (pi->dcb.state == CXGB4_DCB_STATE_HOST) in cxgb4_setpfccfg()
662 pcmd.u.dcb.pfc.type = FW_PORT_DCB_TYPE_PFC; in cxgb4_setpfccfg()
663 pcmd.u.dcb.pfc.pfcen = pi->dcb.pfcen; in cxgb4_setpfccfg()
666 pcmd.u.dcb.pfc.pfcen |= (1 << (7 - priority)); in cxgb4_setpfccfg()
668 pcmd.u.dcb.pfc.pfcen &= (~(1 << (7 - priority))); in cxgb4_setpfccfg()
672 dev_err(adap->pdev_dev, "DCB PFC write failed with %d\n", -err); in cxgb4_setpfccfg()
676 pi->dcb.pfcen = pcmd.u.dcb.pfc.pfcen; in cxgb4_setpfccfg()
684 /* Return DCB capabilities.
716 *caps = pi->dcb.supported; in cxgb4_getcap()
734 if (pi->dcb.msgs & CXGB4_DCB_FW_PGRATE) in cxgb4_getnumtcs()
735 *num = pi->dcb.pg_num_tcs_supported; in cxgb4_getnumtcs()
766 if (!cxgb4_dcb_state_synced(pi->dcb.state)) in cxgb4_getpfcstate()
769 return pi->dcb.pfcen != 0; in cxgb4_getpfcstate()
790 if (!cxgb4_dcb_state_synced(pi->dcb.state)) in __cxgb4_getapp()
802 pcmd.u.dcb.app_priority.type = FW_PORT_DCB_TYPE_APP_ID; in __cxgb4_getapp()
803 pcmd.u.dcb.app_priority.idx = i; in __cxgb4_getapp()
807 dev_err(adap->pdev_dev, "DCB APP read failed with %d\n", in __cxgb4_getapp()
811 if (be16_to_cpu(pcmd.u.dcb.app_priority.protocolid) == app_id) in __cxgb4_getapp()
812 if (pcmd.u.dcb.app_priority.sel_field == app_idtype) in __cxgb4_getapp()
813 return pcmd.u.dcb.app_priority.user_prio_map; in __cxgb4_getapp()
816 if (!pcmd.u.dcb.app_priority.protocolid) in __cxgb4_getapp()
844 if (!cxgb4_dcb_state_synced(pi->dcb.state)) in __cxgb4_setapp()
847 /* DCB info gets thrown away on link up */ in __cxgb4_setapp()
853 pcmd.u.dcb.app_priority.type = FW_PORT_DCB_TYPE_APP_ID; in __cxgb4_setapp()
854 pcmd.u.dcb.app_priority.idx = i; in __cxgb4_setapp()
858 dev_err(adap->pdev_dev, "DCB app table read failed with %d\n", in __cxgb4_setapp()
862 if (be16_to_cpu(pcmd.u.dcb.app_priority.protocolid) == app_id) { in __cxgb4_setapp()
864 pcmd.u.dcb.app_priority.protocolid = 0; in __cxgb4_setapp()
868 if (!pcmd.u.dcb.app_priority.protocolid) in __cxgb4_setapp()
874 dev_err(adap->pdev_dev, "DCB app table full\n"); in __cxgb4_setapp()
880 if (pi->dcb.state == CXGB4_DCB_STATE_HOST) in __cxgb4_setapp()
883 pcmd.u.dcb.app_priority.type = FW_PORT_DCB_TYPE_APP_ID; in __cxgb4_setapp()
884 pcmd.u.dcb.app_priority.protocolid = cpu_to_be16(app_id); in __cxgb4_setapp()
885 pcmd.u.dcb.app_priority.sel_field = app_idtype; in __cxgb4_setapp()
886 pcmd.u.dcb.app_priority.user_prio_map = app_prio; in __cxgb4_setapp()
887 pcmd.u.dcb.app_priority.idx = i; in __cxgb4_setapp()
891 dev_err(adap->pdev_dev, "DCB app table write failed with %d\n", in __cxgb4_setapp()
930 struct port_dcb_info *dcb = &pi->dcb; in cxgb4_ieee_negotiation_complete() local
932 if (dcb->state == CXGB4_DCB_STATE_FW_ALLSYNCED) in cxgb4_ieee_negotiation_complete()
933 if (dcb_subtype && !(dcb->msgs & dcb_subtype)) in cxgb4_ieee_negotiation_complete()
936 return (cxgb4_dcb_state_synced(dcb->state) && in cxgb4_ieee_negotiation_complete()
937 (dcb->supported & DCB_CAP_DCBX_VER_IEEE)); in cxgb4_ieee_negotiation_complete()
944 struct port_dcb_info *dcb = &pi->dcb; in cxgb4_ieee_read_ets() local
950 if (!(dcb->msgs & (CXGB4_DCB_FW_PGID | CXGB4_DCB_FW_PGRATE))) in cxgb4_ieee_read_ets()
953 ets->ets_cap = dcb->pg_num_tcs_supported; in cxgb4_ieee_read_ets()
962 pcmd.u.dcb.pgid.type = FW_PORT_DCB_TYPE_PGID; in cxgb4_ieee_read_ets()
965 dev_err(adap->pdev_dev, "DCB read PGID failed with %d\n", -err); in cxgb4_ieee_read_ets()
969 tc_info = be32_to_cpu(pcmd.u.dcb.pgid.pgid); in cxgb4_ieee_read_ets()
976 pcmd.u.dcb.pgrate.type = FW_PORT_DCB_TYPE_PGRATE; in cxgb4_ieee_read_ets()
979 dev_err(adap->pdev_dev, "DCB read PGRATE failed with %d\n", in cxgb4_ieee_read_ets()
987 ets->tc_tx_bw[i] = pcmd.u.dcb.pgrate.pgrate[i]; in cxgb4_ieee_read_ets()
989 ets->tc_tsa[i] = pcmd.u.dcb.pgrate.tsa[i]; in cxgb4_ieee_read_ets()
1004 struct port_dcb_info *dcb = &pi->dcb; in cxgb4_ieee_get_pfc() local
1008 if (!(dcb->msgs & CXGB4_DCB_FW_PFC)) in cxgb4_ieee_get_pfc()
1011 pfc->pfc_cap = dcb->pfc_num_tcs_supported; in cxgb4_ieee_get_pfc()
1012 pfc->pfc_en = bitswap_1(dcb->pfcen); in cxgb4_ieee_get_pfc()
1077 return pi->dcb.supported; in cxgb4_getdcbx()
1092 /* Can't enable DCB if we haven't successfully negotiated it. in cxgb4_setdcbx()
1094 if (!cxgb4_dcb_state_synced(pi->dcb.state)) in cxgb4_setdcbx()
1102 if (dcb_request != pi->dcb.supported) in cxgb4_setdcbx()
1105 pi->dcb.supported = dcb_request; in cxgb4_setdcbx()
1117 if (!cxgb4_dcb_state_synced(pi->dcb.state)) in cxgb4_getpeer_app()
1126 pcmd.u.dcb.app_priority.type = FW_PORT_DCB_TYPE_APP_ID; in cxgb4_getpeer_app()
1127 pcmd.u.dcb.app_priority.idx = *app_count; in cxgb4_getpeer_app()
1131 dev_err(adap->pdev_dev, "DCB app table read failed with %d\n", in cxgb4_getpeer_app()
1137 if (!pcmd.u.dcb.app_priority.protocolid) in cxgb4_getpeer_app()
1151 if (!cxgb4_dcb_state_synced(pi->dcb.state)) in cxgb4_getpeerapp_tbl()
1156 pcmd.u.dcb.app_priority.type = FW_PORT_DCB_TYPE_APP_ID; in cxgb4_getpeerapp_tbl()
1157 pcmd.u.dcb.app_priority.idx = i; in cxgb4_getpeerapp_tbl()
1161 dev_err(adap->pdev_dev, "DCB app table read failed with %d\n", in cxgb4_getpeerapp_tbl()
1167 if (!pcmd.u.dcb.app_priority.protocolid) in cxgb4_getpeerapp_tbl()
1170 table[i].selector = (pcmd.u.dcb.app_priority.sel_field + 1); in cxgb4_getpeerapp_tbl()
1172 be16_to_cpu(pcmd.u.dcb.app_priority.protocolid); in cxgb4_getpeerapp_tbl()
1174 ffs(pcmd.u.dcb.app_priority.user_prio_map) - 1; in cxgb4_getpeerapp_tbl()
1195 pcmd.u.dcb.pgid.type = FW_PORT_DCB_TYPE_PGID; in cxgb4_cee_peer_getpg()
1198 dev_err(adap->pdev_dev, "DCB read PGID failed with %d\n", -err); in cxgb4_cee_peer_getpg()
1201 pgid = be32_to_cpu(pcmd.u.dcb.pgid.pgid); in cxgb4_cee_peer_getpg()
1207 pcmd.u.dcb.pgrate.type = FW_PORT_DCB_TYPE_PGRATE; in cxgb4_cee_peer_getpg()
1210 dev_err(adap->pdev_dev, "DCB read PGRATE failed with %d\n", in cxgb4_cee_peer_getpg()
1216 pg->pg_bw[i] = pcmd.u.dcb.pgrate.pgrate[i]; in cxgb4_cee_peer_getpg()
1218 pg->tcs_supported = pcmd.u.dcb.pgrate.num_tcs_supported; in cxgb4_cee_peer_getpg()
1235 pfc->pfc_en = bitswap_1(pi->dcb.pfcen); in cxgb4_cee_peer_getpfc()
1237 pfc->tcs_supported = pi->dcb.pfc_num_tcs_supported; in cxgb4_cee_peer_getpfc()