Ejemplo n.º 1
0
int enic_dev_init_prov2(struct enic *enic, struct vic_provinfo *vp)
{
	int err;

	spin_lock(&enic->devcmd_lock);
	err = vnic_dev_init_prov2(enic->vdev,
		(u8 *)vp, vic_provinfo_size(vp));
	spin_unlock(&enic->devcmd_lock);

	return err;
}
Ejemplo n.º 2
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);
	char uuid_str[38];
	char client_mac_str[18];
	u8 *client_mac;
	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,
		VIC_GENERIC_PROV_TLV_OS_TYPE,
		sizeof(os_type), &os_type);

	ENIC_DEVCMD_PROXY_BY_INDEX(vf, err, enic, vnic_dev_init_prov2, (u8 *)vp,
		vic_provinfo_size(vp));
	err = enic_dev_status_to_errno(err);

add_tlv_failure:
	vic_provinfo_free(vp);

	return err;
}