/* Any writes here are only done on kernels that exlicitly need * a specific version, say < 2.6.38 which only support CEE
*/
dcb->dcb_version = FW_PORT_DCB_VER_AUTO;
}
/* Reset a port's Data Center Bridging state. Typically used after a * Link Down event.
*/ void cxgb4_dcb_reset(struct net_device *dev)
{
cxgb4_dcb_cleanup_apps(dev);
cxgb4_dcb_state_init(dev);
}
/* update the dcb port support, if version is IEEE then set it to * FW_PORT_DCB_VER_IEEE and if DCB_CAP_DCBX_VER_CEE is already set then * clear that. and if it is set to CEE then set dcb supported to * DCB_CAP_DCBX_VER_CEE & if DCB_CAP_DCBX_VER_IEEE is set, clear it
*/ staticinlinevoid cxgb4_dcb_update_support(struct port_dcb_info *dcb)
{ if (dcb->dcb_version == FW_PORT_DCB_VER_IEEE) { if (dcb->supported & DCB_CAP_DCBX_VER_CEE)
dcb->supported &= ~DCB_CAP_DCBX_VER_CEE;
dcb->supported |= DCB_CAP_DCBX_VER_IEEE;
} elseif (dcb->dcb_version == FW_PORT_DCB_VER_CEE1D01) { if (dcb->supported & DCB_CAP_DCBX_VER_IEEE)
dcb->supported &= ~DCB_CAP_DCBX_VER_IEEE;
dcb->supported |= DCB_CAP_DCBX_VER_CEE;
}
}
/* Finite State machine for Data Center Bridging.
*/ void cxgb4_dcb_state_fsm(struct net_device *dev, enum cxgb4_dcb_state_input transition_to)
{ struct port_info *pi = netdev2pinfo(dev); struct port_dcb_info *dcb = &pi->dcb; struct adapter *adap = pi->adapter; enum cxgb4_dcb_state current_state = dcb->state;
netdev_dbg(dev, "%s: State change from %d to %d for %s\n",
__func__, dcb->state, transition_to, dev->name);
switch (current_state) { case CXGB4_DCB_STATE_START: { switch (transition_to) { case CXGB4_DCB_INPUT_FW_DISABLED: { /* we're going to use Host DCB */
dcb->state = CXGB4_DCB_STATE_HOST;
dcb->supported = CXGB4_DCBX_HOST_SUPPORT; break;
}
case CXGB4_DCB_INPUT_FW_ENABLED: { /* we're going to use Firmware DCB */
dcb->state = CXGB4_DCB_STATE_FW_INCOMPLETE;
dcb->supported = DCB_CAP_DCBX_LLD_MANAGED; if (dcb->dcb_version == FW_PORT_DCB_VER_IEEE)
dcb->supported |= DCB_CAP_DCBX_VER_IEEE; else
dcb->supported |= DCB_CAP_DCBX_VER_CEE; break;
}
case CXGB4_DCB_INPUT_FW_INCOMPLETE: { /* expected transition */ break;
}
case CXGB4_DCB_INPUT_FW_ALLSYNCED: {
dcb->state = CXGB4_DCB_STATE_FW_ALLSYNCED; break;
}
default: goto bad_state_input;
} break;
}
case CXGB4_DCB_STATE_FW_INCOMPLETE: { if (transition_to != CXGB4_DCB_INPUT_FW_DISABLED) { /* during this CXGB4_DCB_STATE_FW_INCOMPLETE state, * check if the dcb version is changed (there can be * mismatch in default config & the negotiated switch * configuration at FW, so update the dcb support * accordingly.
*/
cxgb4_dcb_update_support(dcb);
} switch (transition_to) { case CXGB4_DCB_INPUT_FW_ENABLED: { /* we're alreaady in firmware DCB mode */ break;
}
case CXGB4_DCB_INPUT_FW_INCOMPLETE: { /* we're already incomplete */ break;
}
case CXGB4_DCB_STATE_FW_ALLSYNCED: { switch (transition_to) { case CXGB4_DCB_INPUT_FW_ENABLED: { /* we're alreaady in firmware DCB mode */ break;
}
case CXGB4_DCB_INPUT_FW_INCOMPLETE: { /* We were successfully running with firmware DCB but * now it's telling us that it's in an "incomplete * state. We need to reset back to a ground state * of incomplete.
*/
cxgb4_dcb_reset(dev);
dcb->state = CXGB4_DCB_STATE_FW_INCOMPLETE;
dcb->supported = CXGB4_DCBX_FW_SUPPORT;
linkwatch_fire_event(dev); break;
}
case CXGB4_DCB_INPUT_FW_ALLSYNCED: { /* we're already all sync'ed * this is only applicable for IEEE or * when another VI already completed negotiaton
*/
dcb->enabled = 1;
linkwatch_fire_event(dev); break;
}
default: goto bad_state_input;
} break;
}
case CXGB4_DCB_STATE_HOST: { switch (transition_to) { case CXGB4_DCB_INPUT_FW_DISABLED: { /* we're alreaady in Host DCB mode */ break;
}
default: goto bad_state_input;
} break;
}
default: goto bad_state_transition;
} return;
bad_state_input:
dev_err(adap->pdev_dev, "cxgb4_dcb_state_fsm: illegal input symbol %d\n",
transition_to); return;
bad_state_transition:
dev_err(adap->pdev_dev, "cxgb4_dcb_state_fsm: bad state transition, state = %d, input = %d\n",
current_state, transition_to);
}
/* Handle a DCB/DCBX update message from the firmware.
*/ void cxgb4_dcb_handle_fw_update(struct adapter *adap, conststruct fw_port_cmd *pcmd)
{ constunion fw_port_dcb *fwdcb = &pcmd->u.dcb; int port = FW_PORT_CMD_PORTID_G(be32_to_cpu(pcmd->op_to_portid)); struct net_device *dev = adap->port[adap->chan_map[port]]; struct port_info *pi = netdev_priv(dev); struct port_dcb_info *dcb = &pi->dcb; int dcb_type = pcmd->u.dcb.pgid.type; int dcb_running_version;
/* Handle Firmware DCB Control messages separately since they drive * our state machine.
*/ if (dcb_type == FW_PORT_DCB_TYPE_CONTROL) { enum cxgb4_dcb_state_input input =
((pcmd->u.dcb.control.all_syncd_pkd &
FW_PORT_CMD_ALL_SYNCD_F)
? CXGB4_DCB_INPUT_FW_ALLSYNCED
: CXGB4_DCB_INPUT_FW_INCOMPLETE);
if (dcb->dcb_version != FW_PORT_DCB_VER_UNKNOWN) {
dcb_running_version = FW_PORT_CMD_DCB_VERSION_G(
be16_to_cpu(
pcmd->u.dcb.control.dcb_version_to_app_state)); if (dcb_running_version == FW_PORT_DCB_VER_CEE1D01 ||
dcb_running_version == FW_PORT_DCB_VER_IEEE) {
dcb->dcb_version = dcb_running_version;
dev_warn(adap->pdev_dev, "Interface %s is running %s\n",
dev->name,
dcb_ver_array[dcb->dcb_version]);
} else {
dev_warn(adap->pdev_dev, "Something screwed up, requested firmware for %s, but firmware returned %s instead\n",
dcb_ver_array[dcb->dcb_version],
dcb_ver_array[dcb_running_version]);
dcb->dcb_version = FW_PORT_DCB_VER_UNKNOWN;
}
}
cxgb4_dcb_state_fsm(dev, input); return;
}
/* It's weird, and almost certainly an error, to get Firmware DCB * messages when we either haven't been told whether we're going to be * doing Host or Firmware DCB; and even worse when we've been told * that we're doing Host DCB!
*/ if (dcb->state == CXGB4_DCB_STATE_START ||
dcb->state == CXGB4_DCB_STATE_HOST) {
dev_err(adap->pdev_dev, "Receiving Firmware DCB messages in State %d\n",
dcb->state); return;
}
/* Now handle the general Firmware DCB update messages ...
*/ switch (dcb_type) { case FW_PORT_DCB_TYPE_PGID:
dcb->pgid = be32_to_cpu(fwdcb->pgid.pgid);
dcb->msgs |= CXGB4_DCB_FW_PGID; break;
/* If DCBx is host-managed, dcb is enabled by outside lldp agents */ if (pi->dcb.state == CXGB4_DCB_STATE_HOST) {
pi->dcb.enabled = enabled; return 0;
}
/* Firmware doesn't provide any mechanism to control the DCB state.
*/ if (enabled != (pi->dcb.state == CXGB4_DCB_STATE_FW_ALLSYNCED)) return 1;
switch (cap_id) { case DCB_CAP_ATTR_PG: case DCB_CAP_ATTR_PFC:
*caps = true; break;
case DCB_CAP_ATTR_PG_TCS: /* 8 priorities for PG represented by bitmap */
*caps = 0x80; break;
case DCB_CAP_ATTR_PFC_TCS: /* 8 priorities for PFC represented by bitmap */
*caps = 0x80; break;
case DCB_CAP_ATTR_GSP:
*caps = true; break;
case DCB_CAP_ATTR_UP2TC: case DCB_CAP_ATTR_BCN:
*caps = false; break;
case DCB_CAP_ATTR_DCBX:
*caps = pi->dcb.supported; break;
default:
*caps = false;
}
return 0;
}
/* Return the number of Traffic Classes for the indicated Traffic Class ID.
*/ staticint cxgb4_getnumtcs(struct net_device *dev, int tcs_id, u8 *num)
{ struct port_info *pi = netdev2pinfo(dev);
switch (tcs_id) { case DCB_NUMTCS_ATTR_PG: if (pi->dcb.msgs & CXGB4_DCB_FW_PGRATE)
*num = pi->dcb.pg_num_tcs_supported; else
*num = 0x8; break;
case DCB_NUMTCS_ATTR_PFC:
*num = 0x8; break;
default: return -EINVAL;
}
return 0;
}
/* Set the number of Traffic Classes supported for the indicated Traffic Class * ID.
*/ staticint cxgb4_setnumtcs(struct net_device *dev, int tcs_id, u8 num)
{ /* Setting the number of Traffic Classes isn't supported.
*/ return -ENOSYS;
}
/* Return whether Priority Flow Control is enabled. */ static u8 cxgb4_getpfcstate(struct net_device *dev)
{ struct port_info *pi = netdev2pinfo(dev);
if (!cxgb4_dcb_state_synced(pi->dcb.state)) returnfalse;
return pi->dcb.pfcen != 0;
}
/* Enable/disable Priority Flow Control. */ staticvoid cxgb4_setpfcstate(struct net_device *dev, u8 state)
{ /* We can't enable/disable Priority Flow Control but we also can't * return an error ...
*/
}
/* Return the Application User Priority Map associated with the specified * Application ID.
*/ staticint __cxgb4_getapp(struct net_device *dev, u8 app_idtype, u16 app_id, int peer)
{ struct port_info *pi = netdev2pinfo(dev); struct adapter *adap = pi->adapter; int i;
if (!cxgb4_dcb_state_synced(pi->dcb.state)) return 0;
for (i = 0; i < CXGB4_MAX_DCBX_APP_SUPPORTED; i++) { struct fw_port_cmd pcmd; int err;
if (peer)
INIT_PORT_DCB_READ_PEER_CMD(pcmd, pi->port_id); else
INIT_PORT_DCB_READ_LOCAL_CMD(pcmd, pi->port_id);
/* Priority for CEE inside dcb_app is bitmask, with 0 being an invalid value */ staticint cxgb4_setapp(struct net_device *dev, u8 app_idtype, u16 app_id,
u8 app_prio)
{ int ret; struct dcb_app app = {
.selector = app_idtype,
.protocol = app_id,
.priority = app_prio,
};
if (app_idtype != DCB_APP_IDTYPE_ETHTYPE &&
app_idtype != DCB_APP_IDTYPE_PORTNUM) return -EINVAL;
/* Convert app_idtype to a format that firmware understands */
ret = __cxgb4_setapp(dev, app_idtype == DCB_APP_IDTYPE_ETHTYPE ?
app_idtype : 3, app_id, app_prio); if (ret) return ret;
return dcb_setapp(dev, &app);
}
/* Return whether IEEE Data Center Bridging has been negotiated.
*/ staticinlineint
cxgb4_ieee_negotiation_complete(struct net_device *dev, enum cxgb4_dcb_fw_msgs dcb_subtype)
{ struct port_info *pi = netdev2pinfo(dev); struct port_dcb_info *dcb = &pi->dcb;
if (dcb->state == CXGB4_DCB_STATE_FW_ALLSYNCED) if (dcb_subtype && !(dcb->msgs & dcb_subtype)) return 0;
/* We reuse this for peer PFC as well, as we can't have it enabled one way */ staticint cxgb4_ieee_get_pfc(struct net_device *dev, struct ieee_pfc *pfc)
{ struct port_info *pi = netdev2pinfo(dev); struct port_dcb_info *dcb = &pi->dcb;
/* Fill in the Application User Priority Map associated with the * specified Application. * Priority for IEEE dcb_app is an integer, with 0 being a valid value
*/ staticint cxgb4_ieee_getapp(struct net_device *dev, struct dcb_app *app)
{ int prio;
if (!cxgb4_ieee_negotiation_complete(dev, CXGB4_DCB_FW_APP_ID)) return -EINVAL; if (!(app->selector && app->protocol)) return -EINVAL;
/* Try querying firmware first, use firmware format */
prio = __cxgb4_getapp(dev, app->selector - 1, app->protocol, 0);
if (prio < 0)
prio = dcb_ieee_getapp_mask(dev, app);
app->priority = ffs(prio) - 1; return 0;
}
/* Write a new Application User Priority Map for the specified Application ID. * Priority for IEEE dcb_app is an integer, with 0 being a valid value
*/ staticint cxgb4_ieee_setapp(struct net_device *dev, struct dcb_app *app)
{ int ret;
if (!cxgb4_ieee_negotiation_complete(dev, CXGB4_DCB_FW_APP_ID)) return -EINVAL; if (!(app->selector && app->protocol)) return -EINVAL;
if (!(app->selector > IEEE_8021QAZ_APP_SEL_ETHERTYPE &&
app->selector < IEEE_8021QAZ_APP_SEL_ANY)) return -EINVAL;
/* change selector to a format that firmware understands */
ret = __cxgb4_setapp(dev, app->selector - 1, app->protocol,
(1 << app->priority)); if (ret) return ret;
/* Filter out requests which exceed our capabilities.
*/ if ((dcb_request & (CXGB4_DCBX_FW_SUPPORT | CXGB4_DCBX_HOST_SUPPORT))
!= dcb_request) return 1;
/* Can't enable DCB if we haven't successfully negotiated it.
*/ if (!cxgb4_dcb_state_synced(pi->dcb.state)) return 1;
/* There's currently no mechanism to allow for the firmware DCBX * negotiation to be changed from the Host Driver. If the caller * requests exactly the same parameters that we already have then * we'll allow them to be successfully "set" ...
*/ if (dcb_request != pi->dcb.supported) return 1;
/* Firmware sends this to us in a formwat that is a bit flipped version * of spec, correct it before we send it to host. This is taken care of * by bit shifting in other uses of pfcen
*/
pfc->pfc_en = bitswap_1(pi->dcb.pfcen);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.