drivers/net/ethernet/cisco/enic/enic_pp.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/cisco/enic/enic_pp.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/cisco/enic/enic_pp.c
Extension
.c
Size
8526 bytes
Lines
354
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 (enic_sriov_enabled(enic)) {
			if (vf < 0 || vf >= enic->num_vfs) {
				*err = -EINVAL;
				goto err_out;
			}
		} else {
			*err = -EOPNOTSUPP;
			goto err_out;
		}
#else
		*err = -EOPNOTSUPP;
		goto err_out;
#endif
	}

	if (vf == PORT_SELF_VF && !enic_is_dynamic(enic)) {
		*err = -EOPNOTSUPP;
		goto err_out;
	}

	*err = 0;
	return 1;

err_out:
	return 0;
}

static int enic_set_port_profile(struct enic *enic, int vf)
{
	struct net_device *netdev = enic->netdev;
	struct enic_port_profile *pp;
	struct vic_provinfo *vp;
	const u8 oui[3] = VIC_PROVINFO_CISCO_OUI;
	const __be16 os_type = htons(VIC_GENERIC_PROV_OS_TYPE_LINUX);
	const u8 *client_mac;
	char uuid_str[38];
	char client_mac_str[18];
	int err;

	ENIC_PP_BY_INDEX(enic, vf, pp, &err);
	if (err)
		return err;

	if (!(pp->set & ENIC_SET_NAME) || !strlen(pp->name))
		return -EINVAL;

	vp = vic_provinfo_alloc(GFP_KERNEL, oui,
		VIC_PROVINFO_GENERIC_TYPE);
	if (!vp)
		return -ENOMEM;

	VIC_PROVINFO_ADD_TLV(vp,
		VIC_GENERIC_PROV_TLV_PORT_PROFILE_NAME_STR,
		strlen(pp->name) + 1, pp->name);

	if (!is_zero_ether_addr(pp->mac_addr)) {
		client_mac = pp->mac_addr;
	} else if (vf == PORT_SELF_VF) {
		client_mac = netdev->dev_addr;
	} else {
		netdev_err(netdev, "Cannot find pp mac address "
			"for VF %d\n", vf);
		err = -EINVAL;
		goto add_tlv_failure;
	}

	VIC_PROVINFO_ADD_TLV(vp,
		VIC_GENERIC_PROV_TLV_CLIENT_MAC_ADDR,
		ETH_ALEN, client_mac);

	snprintf(client_mac_str, sizeof(client_mac_str), "%pM", client_mac);
	VIC_PROVINFO_ADD_TLV(vp,
		VIC_GENERIC_PROV_TLV_CLUSTER_PORT_UUID_STR,
		sizeof(client_mac_str), client_mac_str);

	if (pp->set & ENIC_SET_INSTANCE) {
		sprintf(uuid_str, "%pUB", pp->instance_uuid);
		VIC_PROVINFO_ADD_TLV(vp,
			VIC_GENERIC_PROV_TLV_CLIENT_UUID_STR,
			sizeof(uuid_str), uuid_str);
	}

	if (pp->set & ENIC_SET_HOST) {
		sprintf(uuid_str, "%pUB", pp->host_uuid);
		VIC_PROVINFO_ADD_TLV(vp,
			VIC_GENERIC_PROV_TLV_HOST_UUID_STR,
			sizeof(uuid_str), uuid_str);
	}

	VIC_PROVINFO_ADD_TLV(vp,

Annotation

Implementation Notes