xref: /linux/drivers/net/ethernet/cisco/enic/vnic_vic.h (revision be239684b18e1cdcafcf8c7face4a2f562c745ad)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Copyright 2010 Cisco Systems, Inc.  All rights reserved. */
3 
4 #ifndef _VNIC_VIC_H_
5 #define _VNIC_VIC_H_
6 
7 /* Note: All integer fields in NETWORK byte order */
8 
9 /* Note: String field lengths include null char */
10 
11 #define VIC_PROVINFO_CISCO_OUI		{ 0x00, 0x00, 0x0c }
12 #define VIC_PROVINFO_GENERIC_TYPE		0x4
13 
14 enum vic_generic_prov_tlv_type {
15 	VIC_GENERIC_PROV_TLV_PORT_PROFILE_NAME_STR = 0,
16 	VIC_GENERIC_PROV_TLV_CLIENT_MAC_ADDR = 1,
17 	VIC_GENERIC_PROV_TLV_CLIENT_NAME_STR = 2,
18 	VIC_GENERIC_PROV_TLV_CLUSTER_PORT_NAME_STR = 3,
19 	VIC_GENERIC_PROV_TLV_CLUSTER_PORT_UUID_STR = 4,
20 	VIC_GENERIC_PROV_TLV_CLUSTER_UUID_STR = 5,
21 	VIC_GENERIC_PROV_TLV_CLUSTER_NAME_STR = 7,
22 	VIC_GENERIC_PROV_TLV_HOST_UUID_STR = 8,
23 	VIC_GENERIC_PROV_TLV_CLIENT_UUID_STR = 9,
24 	VIC_GENERIC_PROV_TLV_INCARNATION_NUMBER = 10,
25 	VIC_GENERIC_PROV_TLV_OS_TYPE = 11,
26 	VIC_GENERIC_PROV_TLV_OS_VENDOR = 12,
27 	VIC_GENERIC_PROV_TLV_CLIENT_TYPE = 15,
28 };
29 
30 enum vic_generic_prov_os_type {
31 	VIC_GENERIC_PROV_OS_TYPE_UNKNOWN = 0,
32 	VIC_GENERIC_PROV_OS_TYPE_ESX = 1,
33 	VIC_GENERIC_PROV_OS_TYPE_LINUX = 2,
34 	VIC_GENERIC_PROV_OS_TYPE_WINDOWS = 3,
35 	VIC_GENERIC_PROV_OS_TYPE_SOLARIS = 4,
36 };
37 
38 struct vic_provinfo {
39 	u8 oui[3];		/* OUI of data provider */
40 	u8 type;		/* provider-specific type */
41 	u32 length;		/* length of data below */
42 	u32 num_tlvs;		/* number of tlvs */
43 	struct vic_provinfo_tlv {
44 		u16 type;
45 		u16 length;
46 		u8 value[0];
47 	} tlv[];
48 } __packed;
49 
50 #define VIC_PROVINFO_ADD_TLV(vp, tlvtype, tlvlen, data) \
51 	do { \
52 		err = vic_provinfo_add_tlv(vp, tlvtype, tlvlen, data); \
53 		if (err) \
54 			goto add_tlv_failure; \
55 	} while (0)
56 
57 #define VIC_PROVINFO_MAX_DATA		1385
58 #define VIC_PROVINFO_MAX_TLV_DATA (VIC_PROVINFO_MAX_DATA - \
59 	sizeof(struct vic_provinfo))
60 
61 struct vic_provinfo *vic_provinfo_alloc(gfp_t flags, const u8 *oui,
62 	const u8 type);
63 void vic_provinfo_free(struct vic_provinfo *vp);
64 int vic_provinfo_add_tlv(struct vic_provinfo *vp, u16 type, u16 length,
65 	const void *value);
66 size_t vic_provinfo_size(struct vic_provinfo *vp);
67 
68 #endif	/* _VNIC_VIC_H_ */
69