aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/enic/vnic_vic.c
diff options
context:
space:
mode:
authorScott Feldman <scofeldm@cisco.com>2010-05-18 01:50:19 -0400
committerDavid S. Miller <davem@davemloft.net>2010-05-18 01:50:19 -0400
commitf8bd909183acffad68780b10c1cdf36161cfd5d1 (patch)
treeaefec6e6f1e67e93bc1b2ec223f974a4cd34f00f /drivers/net/enic/vnic_vic.c
parent57b610805ce92dbd79fc97509f80fa5391b99623 (diff)
net: Add ndo_{set|get}_vf_port support for enic dynamic vnics
Add enic ndo_{set|get}_vf_port ops to support setting/getting port-profile for enic dynamic devices. Enic dynamic devices are just like normal enic eth devices except dynamic enics require an extra configuration step to assign a port-profile identifier to the interface before the interface is useable. Once a port-profile is assigned, link comes up on the interface and is ready for I/O. The port-profile is used to configure the network port assigned to the interface. The network port configuration includes VLAN membership, QoS policies, and port security settings typical of a data center network. A dynamic enic initially has a zero-mac address. Before a port-profile is assigned, a valid non-zero unicast mac address should be assign to the dynamic enic interface. Signed-off-by: Scott Feldman <scofeldm@cisco.com> Signed-off-by: Roopa Prabhu <roprabhu@cisco.com>
Diffstat (limited to 'drivers/net/enic/vnic_vic.c')
-rw-r--r--drivers/net/enic/vnic_vic.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/drivers/net/enic/vnic_vic.c b/drivers/net/enic/vnic_vic.c
new file mode 100644
index 000000000000..d769772998c6
--- /dev/null
+++ b/drivers/net/enic/vnic_vic.c
@@ -0,0 +1,73 @@
1/*
2 * Copyright 2010 Cisco Systems, Inc. All rights reserved.
3 *
4 * This program is free software; you may redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
9 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
11 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
12 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
13 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
14 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
15 * SOFTWARE.
16 *
17 */
18
19#include <linux/kernel.h>
20#include <linux/errno.h>
21#include <linux/types.h>
22#include <linux/slab.h>
23
24#include "vnic_vic.h"
25
26struct vic_provinfo *vic_provinfo_alloc(gfp_t flags, u8 *oui, u8 type)
27{
28 struct vic_provinfo *vp = kzalloc(VIC_PROVINFO_MAX_DATA, flags);
29
30 if (!vp || !oui)
31 return NULL;
32
33 memcpy(vp->oui, oui, sizeof(vp->oui));
34 vp->type = type;
35 vp->length = htonl(sizeof(vp->num_tlvs));
36
37 return vp;
38}
39
40void vic_provinfo_free(struct vic_provinfo *vp)
41{
42 kfree(vp);
43}
44
45int vic_provinfo_add_tlv(struct vic_provinfo *vp, u16 type, u16 length,
46 void *value)
47{
48 struct vic_provinfo_tlv *tlv;
49
50 if (!vp || !value)
51 return -EINVAL;
52
53 if (ntohl(vp->length) + sizeof(*tlv) + length >
54 VIC_PROVINFO_MAX_TLV_DATA)
55 return -ENOMEM;
56
57 tlv = (struct vic_provinfo_tlv *)((u8 *)vp->tlv +
58 ntohl(vp->length) - sizeof(vp->num_tlvs));
59
60 tlv->type = htons(type);
61 tlv->length = htons(length);
62 memcpy(tlv->value, value, length);
63
64 vp->num_tlvs = htonl(ntohl(vp->num_tlvs) + 1);
65 vp->length = htonl(ntohl(vp->length) + sizeof(*tlv) + length);
66
67 return 0;
68}
69
70size_t vic_provinfo_size(struct vic_provinfo *vp)
71{
72 return vp ? ntohl(vp->length) + sizeof(*vp) - sizeof(vp->num_tlvs) : 0;
73}