From patchwork Wed Dec 8 04:32:33 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Christian Benvenuti (benve)" X-Patchwork-Id: 74630 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id E3400B70AF for ; Wed, 8 Dec 2010 15:32:37 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752053Ab0LHEce (ORCPT ); Tue, 7 Dec 2010 23:32:34 -0500 Received: from sj-iport-5.cisco.com ([171.68.10.87]:58624 "EHLO sj-iport-5.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750916Ab0LHEcd (ORCPT ); Tue, 7 Dec 2010 23:32:33 -0500 Authentication-Results: sj-iport-5.cisco.com; dkim=neutral (message not signed) header.i=none X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EAA+Z/kyrR7H+/2dsb2JhbACDU593caVBikOQe4EhgzVzBIRiiyg X-IronPort-AV: E=Sophos;i="4.59,314,1288569600"; d="scan'208";a="299039263" Received: from sj-core-2.cisco.com ([171.71.177.254]) by sj-iport-5.cisco.com with ESMTP; 08 Dec 2010 04:32:32 +0000 Received: from savbu-pc100.cisco.com (savbu-pc100.cisco.com [10.193.164.29]) by sj-core-2.cisco.com (8.13.8/8.14.3) with ESMTP id oB84WX1b021966; Wed, 8 Dec 2010 04:32:33 GMT Subject: [RFC][net-next-2.6 PATCH 2/2] Update enic drv to support IFLA_PORT_PROTO_* attributes To: davem@davemloft.net From: Christian Benvenuti Cc: netdev@vger.kernel.org Date: Tue, 07 Dec 2010 20:32:33 -0800 Message-ID: <20101208043106.16856.78100.stgit@savbu-pc100.cisco.com> In-Reply-To: <20101208042925.16856.89232.stgit@savbu-pc100.cisco.com> References: <20101208042925.16856.89232.stgit@savbu-pc100.cisco.com> User-Agent: StGit/0.15 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Christian Benvenuti NOTE: Since there are other enic patches currently waiting for approval on netdev, I will update and re-send this patch should any of the other patches get accepted in the meantime. Signed-off-by: Christian Benvenuti Signed-off-by: Roopa Prabhu Signed-off-by: David Wang --- drivers/net/enic/enic.h | 2 + drivers/net/enic/enic_main.c | 73 +++++++++++++++++++++++++++++++++++------- 2 files changed, 62 insertions(+), 13 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/enic/enic.h b/drivers/net/enic/enic.h index 7067254..a930fb9 100644 --- a/drivers/net/enic/enic.h +++ b/drivers/net/enic/enic.h @@ -32,7 +32,7 @@ #define DRV_NAME "enic" #define DRV_DESCRIPTION "Cisco VIC Ethernet NIC Driver" -#define DRV_VERSION "1.4.1.7" +#define DRV_VERSION "1.4.1.7nl" #define DRV_COPYRIGHT "Copyright 2008-2010 Cisco Systems, Inc" #define ENIC_BARS_MAX 6 diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c index 9f293fa..c15c302 100644 --- a/drivers/net/enic/enic_main.c +++ b/drivers/net/enic/enic_main.c @@ -1223,24 +1223,14 @@ static int enic_set_port_profile(struct enic *enic, u8 *mac) return 0; } -static int enic_set_vf_port(struct net_device *netdev, int vf, +static void enic_set_vf_port_parse_global_attr(struct enic *enic, struct nlattr *port[]) { - struct enic *enic = netdev_priv(netdev); - - memset(&enic->pp, 0, sizeof(enic->pp)); - if (port[IFLA_PORT_REQUEST]) { enic->pp.set |= ENIC_SET_REQUEST; enic->pp.request = nla_get_u8(port[IFLA_PORT_REQUEST]); } - if (port[IFLA_PORT_PROFILE]) { - enic->pp.set |= ENIC_SET_NAME; - memcpy(enic->pp.name, nla_data(port[IFLA_PORT_PROFILE]), - PORT_PROFILE_MAX); - } - if (port[IFLA_PORT_INSTANCE_UUID]) { enic->pp.set |= ENIC_SET_INSTANCE; memcpy(enic->pp.instance_uuid, @@ -1252,6 +1242,57 @@ static int enic_set_vf_port(struct net_device *netdev, int vf, memcpy(enic->pp.host_uuid, nla_data(port[IFLA_PORT_HOST_UUID]), PORT_UUID_MAX); } +} + +static void enic_set_vf_port_parse_legacy_attr(struct enic *enic, + struct nlattr *port[]) +{ + if (port[IFLA_PORT_PROFILE]) { + enic->pp.set |= ENIC_SET_NAME; + memcpy(enic->pp.name, nla_data(port[IFLA_PORT_PROFILE]), + PORT_PROFILE_MAX); + } +} + +static int enic_set_vf_port_parse_proto_attr(struct enic *enic, + struct nlattr *port[]) +{ + struct nlattr *tb_8021qbh[IFLA_PORT_8021QBH_MAX+1]; + int err = 0; + + if (!port[IFLA_PORT_PROTO_8021QBH]) + return -1; + + err = rtnl_link_parse_port_proto(PORT_PROTO_8021QBH, + port[IFLA_PORT_PROTO_8021QBH], + tb_8021qbh); + if (err < 0) + goto errout; + + if (tb_8021qbh[IFLA_PORT_8021QBH_PROFILE]) { + enic->pp.set |= ENIC_SET_NAME; + memcpy(enic->pp.name, + nla_data(tb_8021qbh[IFLA_PORT_8021QBH_PROFILE]), + PORT_PROFILE_MAX); + } + +errout: + return err; +} + +static int enic_set_vf_port(struct net_device *netdev, int vf, + struct nlattr *port[]) +{ + struct enic *enic = netdev_priv(netdev); + int err = 0; + + memset(&enic->pp, 0, sizeof(enic->pp)); + + enic_set_vf_port_parse_global_attr(enic, port); + + err = enic_set_vf_port_parse_proto_attr(enic, port); + if (err < 0) + enic_set_vf_port_parse_legacy_attr(enic, port); /* don't support VFs, yet */ if (vf != PORT_SELF_VF) @@ -1280,6 +1321,7 @@ static int enic_get_vf_port(struct net_device *netdev, int vf, struct enic *enic = netdev_priv(netdev); int err, error, done; u16 response = PORT_PROFILE_RESPONSE_SUCCESS; + struct nlattr *proto; if (!(enic->pp.set & ENIC_SET_APPLIED)) return -ENODATA; @@ -1309,7 +1351,7 @@ static int enic_get_vf_port(struct net_device *netdev, int vf, NLA_PUT_U16(skb, IFLA_PORT_REQUEST, enic->pp.request); NLA_PUT_U16(skb, IFLA_PORT_RESPONSE, response); - if (enic->pp.set & ENIC_SET_NAME) + if (enic->pp.set & ENIC_SET_NAME) /* Deprecated */ NLA_PUT(skb, IFLA_PORT_PROFILE, PORT_PROFILE_MAX, enic->pp.name); if (enic->pp.set & ENIC_SET_INSTANCE) @@ -1319,6 +1361,13 @@ static int enic_get_vf_port(struct net_device *netdev, int vf, NLA_PUT(skb, IFLA_PORT_HOST_UUID, PORT_UUID_MAX, enic->pp.host_uuid); + proto = nla_nest_start(skb, IFLA_PORT_PROTO_8021QBH); + if (proto == NULL) + goto nla_put_failure; + NLA_PUT(skb, IFLA_PORT_8021QBH_PROFILE, PORT_PROFILE_MAX, + enic->pp.name); + nla_nest_end(skb, proto); + return 0; nla_put_failure: