From patchwork Wed Jul 18 10:59:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Or Gerlitz X-Patchwork-Id: 171645 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 625EF2C00B8 for ; Wed, 18 Jul 2012 21:00:35 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754007Ab2GRLA3 (ORCPT ); Wed, 18 Jul 2012 07:00:29 -0400 Received: from eu1sys200aog115.obsmtp.com ([207.126.144.139]:54104 "HELO eu1sys200aog115.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1753856Ab2GRLAZ (ORCPT ); Wed, 18 Jul 2012 07:00:25 -0400 Received: from mtlsws123.lab.mtl.com ([82.166.227.17]) (using TLSv1) by eu1sys200aob115.postini.com ([207.126.147.11]) with SMTP ID DSNKUAaXPDRjX38uy6P+nOvzpSnbSVsNN7Px@postini.com; Wed, 18 Jul 2012 11:00:24 UTC Received: from r-vnc04.lab.mtl.com (r-vnc04.lab.mtl.com [10.208.0.116]) by mtlsws123.lab.mtl.com (8.13.8/8.13.8) with ESMTP id q6IB06NQ028846; Wed, 18 Jul 2012 14:00:09 +0300 From: Or Gerlitz To: davem@davemloft.net Cc: roland@kernel.org, netdev@vger.kernel.org, ali@mellanox.com, sean.hefty@intel.com, shlomop@mellanox.com, Erez Shitrit , Or Gerlitz Subject: [PATCH net-next V1 4/9] net/eipoib: Add private header file Date: Wed, 18 Jul 2012 13:59:57 +0300 Message-Id: <1342609202-32427-5-git-send-email-ogerlitz@mellanox.com> X-Mailer: git-send-email 1.7.8.2 In-Reply-To: <1342609202-32427-1-git-send-email-ogerlitz@mellanox.com> References: <1342609202-32427-1-git-send-email-ogerlitz@mellanox.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Erez Shitrit The header file includes all structures, macros and non-static functions which are of use by the driver. Signed-off-by: Erez Shitrit Signed-off-by: Or Gerlitz --- drivers/net/eipoib/eth_ipoib.h | 227 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 227 insertions(+), 0 deletions(-) create mode 100644 drivers/net/eipoib/eth_ipoib.h diff --git a/drivers/net/eipoib/eth_ipoib.h b/drivers/net/eipoib/eth_ipoib.h new file mode 100644 index 0000000..408cef5 --- /dev/null +++ b/drivers/net/eipoib/eth_ipoib.h @@ -0,0 +1,227 @@ +/* + * Copyright (c) 2012 Mellanox Technologies. All rights reserved + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * openfabric.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef _LINUX_ETH_IPOIB_H +#define _LINUX_ETH_IPOIB_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +/* macros and definitions */ +#define DRV_VERSION "1.0.0" +#define DRV_RELDATE "June 1, 2012" +#define DRV_NAME "eth_ipoib" +#define SDRV_NAME "ipoib" +#define DRV_DESCRIPTION "IP-over-InfiniBand Para Virtualized Driver" +#define EIPOIB_ABI_VER 1 + +#undef pr_fmt +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#define GID_LEN 16 +#define GUID_LEN 8 + +#define PARENT_VLAN_FEATURES \ + (NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_TX | \ + NETIF_F_HW_VLAN_FILTER) + +#define parent_for_each_slave(_parent, slave) \ + list_for_each_entry(slave, &(_parent)->slave_list, list)\ + +#define PARENT_IS_OK(_parent) \ + (((_parent)->dev->flags & IFF_UP) && \ + netif_running((_parent)->dev) && \ + ((_parent)->slave_cnt > 0)) + +#define IS_E_IPOIB_PROTO(_proto) \ + (((_proto) == htons(ETH_P_ARP)) || \ + ((_proto) == htons(ETH_P_RARP)) || \ + ((_proto) == htons(ETH_P_IP))) + +enum eipoib_emac_guest_info { + VALID, + MIGRATED_OUT, + INVALID, +}; + +/* structs */ +struct eth_arp_data { + u8 arp_sha[ETH_ALEN]; + __be32 arp_sip; + u8 arp_dha[ETH_ALEN]; + __be32 arp_dip; +} __packed; + +struct ipoib_arp_data { + u8 arp_sha[INFINIBAND_ALEN]; + __be32 arp_sip; + u8 arp_dha[INFINIBAND_ALEN]; + __be32 arp_dip; +} __packed; + +/* live migration support structures: */ +struct ip_member { + __be32 ip; + struct list_head list; +}; + +/* + * for each slave (emac) saves all the ip over that mac. + * the parent keeps that list for live migration. + */ +struct guest_emac_info { + u8 emac[ETH_ALEN]; + u16 vlan; + struct list_head ip_list; + struct list_head list; + enum eipoib_emac_guest_info rec_state; + int num_of_retries; +}; + +struct neigh { + struct list_head list; + u8 emac[ETH_ALEN]; + u8 imac[INFINIBAND_ALEN]; + /* this part is used for neigh_add_list */ + char cmd[PAGE_SIZE]; +}; + +struct slave { + struct net_device *dev; + struct slave *next; + struct slave *prev; + int index; + struct list_head list; + unsigned long jiffies; + s8 link; + s8 state; + u16 pkey; + u16 vlan; + u8 emac[ETH_ALEN]; + u8 imac[INFINIBAND_ALEN]; + struct list_head neigh_list; + /* this part is used for vif_add_list */ + char cmd[PAGE_SIZE]; +}; + +struct port_stats { + /* update PORT_STATS_LEN (number of stat fields)accordingly */ + unsigned long tx_parent_dropped; + unsigned long tx_vif_miss; + unsigned long tx_neigh_miss; + unsigned long tx_vlan; + unsigned long tx_shared; + unsigned long tx_proto_errors; + unsigned long tx_skb_errors; + unsigned long tx_slave_err; + + unsigned long rx_parent_dropped; + unsigned long rx_vif_miss; + unsigned long rx_neigh_miss; + unsigned long rx_vlan; + unsigned long rx_shared; + unsigned long rx_proto_errors; + unsigned long rx_skb_errors; + unsigned long rx_slave_err; +}; + +struct parent { + struct net_device *dev; + int index; + struct neigh_parms nparms; + struct list_head slave_list; + /* never change this value outside the attach/detach wrappers */ + s32 slave_cnt; + rwlock_t lock; + struct net_device_stats stats; + struct port_stats port_stats; + struct list_head parent_list; + struct dev_mc_list *mc_list; + u16 flags; + struct list_head vlan_list; + struct workqueue_struct *wq; + s8 kill_timers; + struct delayed_work neigh_learn_work; + struct delayed_work vif_learn_work; + struct list_head neigh_add_list; + union ib_gid gid; + char ipoib_main_interface[IFNAMSIZ]; + struct list_head emac_ip_list; + struct delayed_work emac_ip_work; + struct delayed_work migrate_out_work; +}; + +#define eipoib_slave_get_rcu(dev) \ + ((struct slave *) rcu_dereference(dev->rx_handler_data)) + +/* name space support for sys/fs */ +struct eipoib_net { + struct net *net; /* Associated network namespace */ + struct class_attribute class_attr_eipoib_interfaces; +}; + +/* exported from main.c */ +extern int eipoib_net_id; +extern struct list_head parent_dev_list; + +/* functions prototypes */ +int mod_create_sysfs(struct eipoib_net *eipoib_n); +void mod_destroy_sysfs(struct eipoib_net *eipoib_n); +void parent_destroy_sysfs_entry(struct parent *parent); +int parent_create_sysfs_entry(struct parent *parent); +int create_slave_symlinks(struct net_device *master, + struct net_device *slave); +void destroy_slave_symlinks(struct net_device *master, + struct net_device *slave); +int parent_enslave(struct net_device *parent_dev, + struct net_device *slave_dev); +int parent_release_slave(struct net_device *parent_dev, + struct net_device *slave_dev); +struct neigh *parent_get_neigh_cmd(char op, char *ifname, + u8 *remac, u8 *rimac); +struct slave *parent_get_vif_cmd(char op, char *ifname, u8 *lemac); +ssize_t __parent_store_neighs(struct device *d, + struct device_attribute *attr, + const char *buffer, size_t count); +void parent_set_ethtool_ops(struct net_device *dev); + +#endif /* _LINUX_ETH_IPOIB_H */