drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c
Extension
.c
Size
33781 bytes
Lines
1282
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (dcb->dcb_version == FW_PORT_DCB_VER_IEEE) {
			app.priority = dcb->app_priority[i].user_prio_map;
			app.selector = dcb->app_priority[i].sel_field + 1;
			err = dcb_ieee_delapp(dev, &app);
		} else {
			app.selector = !!(dcb->app_priority[i].sel_field);
			err = dcb_setapp(dev, &app);
		}

		if (err) {
			dev_err(adap->pdev_dev,
				"Failed DCB Clear %s Application Priority: sel=%d, prot=%d, err=%d\n",
				dcb_ver_array[dcb->dcb_version], app.selector,
				app.protocol, -err);
			break;
		}
	}
}

/* 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
 */
static inline void 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;
	} else if (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;
		}

Annotation

Implementation Notes