From patchwork Fri Jul 26 12:09:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 262138 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 9A7BF2C00E4 for ; Fri, 26 Jul 2013 22:11:02 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758651Ab3GZMKM (ORCPT ); Fri, 26 Jul 2013 08:10:12 -0400 Received: from mail-ea0-f173.google.com ([209.85.215.173]:50425 "EHLO mail-ea0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758592Ab3GZMKG (ORCPT ); Fri, 26 Jul 2013 08:10:06 -0400 Received: by mail-ea0-f173.google.com with SMTP id g10so1527419eak.32 for ; Fri, 26 Jul 2013 05:10:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=QNW1aHsplUKT7RxNP1tFy7sU/BQpj1YdWFAtYGxsoW0=; b=LFq71mc1UJp9j07Jbi0Q+B8XRz3K2YYzINrIW0OGLB224PUuIbOKf3zlHBeK2rluIp 0qabnU+62Zduap9sNDyeU4MWZjG3IVPPzlZKeRDtMEKBpJNqo3ATBD92LCIOnLopZ9Ik zlijllIwrM+TYJcgrG1pyAGq/MBNKpXD+BKe5vluI5Lm/ZTlAI4h03Sl13A1zKGKMrgn ePEAmJlRr4I1o4dgqdvawpkDnNkF2Y6ryyCUzTN8QxzfYBelJdBS+vrD3DESdjHlqAZ+ cgFQAVn9tShMp/fkOfSOHQKJhuV3qCP/+dLyuwlogGib2TDyNY/c3y0LE09GBkHDdx+L i+MA== X-Received: by 10.14.205.72 with SMTP id i48mr47187980eeo.139.1374840604952; Fri, 26 Jul 2013 05:10:04 -0700 (PDT) Received: from localhost (nat-pool-brq-t.redhat.com. [209.132.186.34]) by mx.google.com with ESMTPSA id m1sm80665765eex.17.2013.07.26.05.10.02 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 26 Jul 2013 05:10:03 -0700 (PDT) From: Jiri Pirko To: netdev@vger.kernel.org Cc: davem@davemloft.net, stephen@networkplumber.org, Narendra_K@Dell.com, bhutchings@solarflare.com, john.r.fastabend@intel.com, or.gerlitz@gmail.com, jeffrey.t.kirsher@intel.com, jesse.brandeburg@intel.com, bruce.w.allan@intel.com, carolyn.wyborny@intel.com, donald.c.skidmore@intel.com, gregory.v.rose@intel.com, peter.p.waskiewicz.jr@intel.com, alexander.h.duyck@intel.com, john.ronciak@intel.com, tushar.n.dave@intel.com, matthew.vick@intel.com, mitch.a.williams@intel.com, vyasevic@redhat.com, amwang@redhat.com, johannes@sipsolutions.net Subject: [patch net-next v5 1/4] net: add ndo to get id of physical port of the device Date: Fri, 26 Jul 2013 14:09:53 +0200 Message-Id: <1374840596-5748-2-git-send-email-jiri@resnulli.us> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1374840596-5748-1-git-send-email-jiri@resnulli.us> References: <1374840596-5748-1-git-send-email-jiri@resnulli.us> X-Gm-Message-State: ALoCoQlWE8q7HjKdQbBl8gsaeD0PsLNZvaEdD4oNzU22WijIkFBOt97TIeIrVOCW+l6szJKp3T6A Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch adds a ndo for getting physical port of the device. Driver which is aware of being virtual function of some physical port should implement this ndo. This is applicable not only for IOV, but for other solutions (NPAR, multichannel) as well. Basically if there is possible to have multiple netdevs on the single hw port. Signed-off-by: Jiri Pirko Acked-by: Ben Hutchings --- include/linux/netdevice.h | 20 ++++++++++++++++++++ net/core/dev.c | 18 ++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 3ca60b0..875f869 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -728,6 +728,16 @@ struct netdev_fcoe_hbainfo { }; #endif +#define MAX_PHYS_PORT_ID_LEN 32 + +/* This structure holds a unique identifier to identify the + * physical port used by a netdevice. + */ +struct netdev_phys_port_id { + unsigned char id[MAX_PHYS_PORT_ID_LEN]; + unsigned char id_len; +}; + /* * This structure defines the management hooks for network devices. * The following hooks can be defined; unless noted otherwise, they are @@ -932,6 +942,12 @@ struct netdev_fcoe_hbainfo { * that determine carrier state from physical hardware properties (eg * network cables) or protocol-dependent mechanisms (eg * USB_CDC_NOTIFY_NETWORK_CONNECTION) should NOT implement this function. + * + * int (*ndo_get_phys_port_id)(struct net_device *dev, + * struct netdev_phys_port_id *ppid); + * Called to get ID of physical port of this device. If driver does + * not implement this, it is assumed that the hw is not able to have + * multiple net devices on single physical port. */ struct net_device_ops { int (*ndo_init)(struct net_device *dev); @@ -1060,6 +1076,8 @@ struct net_device_ops { struct nlmsghdr *nlh); int (*ndo_change_carrier)(struct net_device *dev, bool new_carrier); + int (*ndo_get_phys_port_id)(struct net_device *dev, + struct netdev_phys_port_id *ppid); }; /* @@ -2315,6 +2333,8 @@ extern int dev_set_mac_address(struct net_device *, struct sockaddr *); extern int dev_change_carrier(struct net_device *, bool new_carrier); +extern int dev_get_phys_port_id(struct net_device *dev, + struct netdev_phys_port_id *ppid); extern int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev, struct netdev_queue *txq); diff --git a/net/core/dev.c b/net/core/dev.c index dfd9f5d..58eb802 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -4989,6 +4989,24 @@ int dev_change_carrier(struct net_device *dev, bool new_carrier) EXPORT_SYMBOL(dev_change_carrier); /** + * dev_get_phys_port_id - Get device physical port ID + * @dev: device + * @ppid: port ID + * + * Get device physical port ID + */ +int dev_get_phys_port_id(struct net_device *dev, + struct netdev_phys_port_id *ppid) +{ + const struct net_device_ops *ops = dev->netdev_ops; + + if (!ops->ndo_get_phys_port_id) + return -EOPNOTSUPP; + return ops->ndo_get_phys_port_id(dev, ppid); +} +EXPORT_SYMBOL(dev_get_phys_port_id); + +/** * dev_new_index - allocate an ifindex * @net: the applicable net namespace *