PERFORCE change 118931 for review

Kip Macy kmacy at FreeBSD.org
Sun Apr 29 07:36:01 UTC 2007


http://perforce.freebsd.org/chv.cgi?CH=118931

Change 118931 by kmacy at kmacy_vt-x:opentoe_init on 2007/04/29 07:35:08

	more BSD conversion

Affected files ...

.. //depot/projects/opentoe/sys/dev/cxgb/ulp/toecore/toe_offload.c#2 edit
.. //depot/projects/opentoe/sys/dev/cxgb/ulp/toecore/toe_offload.h#3 edit
.. //depot/projects/opentoe/sys/dev/cxgb/ulp/toecore/toedev.c#4 edit
.. //depot/projects/opentoe/sys/dev/cxgb/ulp/toecore/toedev.h#3 edit

Differences ...

==== //depot/projects/opentoe/sys/dev/cxgb/ulp/toecore/toe_offload.c#2 (text+ko) ====

@@ -1,24 +1,34 @@
-/*
- * TCP offload support.
- *
- * Copyright (C) 2003-2006 Chelsio Communications.  All rights reserved.
- *
- * Written by Dimitris Michailidis (dm at chelsio.com)
- *
- * This program is free software; you can redistribute it and/or modify it 
- * under the terms of the GNU General Public License as published by the Free 
- * Software Foundation; either version 2 of the License, or (at your option) 
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT 
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for 
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 
- * Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- */
+/**************************************************************************
+
+Copyright (c) 2007, Chelsio Inc.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+    this list of conditions and the following disclaimer.
+
+ 2. Neither the name of the Chelsio Corporation nor the names of its
+    contributors may be used to endorse or promote products derived from
+    this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+***************************************************************************/
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
 
 #include <linux/module.h>
 #include <linux/notifier.h>
@@ -38,27 +48,27 @@
 static DECLARE_MUTEX(notify_mutex);
 static RAW_NOTIFIER_HEAD(listen_offload_notify_list);
 
-int register_listen_offload_notifier(struct notifier_block *nb)
+int
+register_listen_offload_notifier(struct notifier_block *nb)
 {
 	int err;
 
-	down(&notify_mutex);
+	mtx_lock(&notify_mutex);
 	err = raw_notifier_chain_register(&listen_offload_notify_list, nb);
-	up(&notify_mutex);
+	mtx_unlock&notify_mutex);
 	return err;
 }
-EXPORT_SYMBOL(register_listen_offload_notifier);
 
-int unregister_listen_offload_notifier(struct notifier_block *nb)
+int
+unregister_listen_offload_notifier(struct notifier_block *nb)
 {
 	int err;
 
-	down(&notify_mutex);
+	mtx_lock(&notify_mutex);
 	err = raw_notifier_chain_unregister(&listen_offload_notify_list, nb);
-	up(&notify_mutex);
+	mtx_unlock&notify_mutex);
 	return err;
 }
-EXPORT_SYMBOL(unregister_listen_offload_notifier);
 
 #if defined(CONFIG_TCP_OFFLOAD) || \
     (defined(CONFIG_TCP_OFFLOAD_MODULE) && defined(MODULE))
@@ -69,7 +79,8 @@
  *
  * Returns 1 if the connection is offloaded and 0 otherwise.
  */
-int tcp_connect_offload(struct sock *sk)
+int
+tcp_connect_offload(struct socket *so)
 {
 	if (sk->sk_route_caps & NETIF_F_TCPIP_OFFLOAD) {
 		struct net_device *netdev = __sk_dst_get(sk)->dev;
@@ -83,7 +94,6 @@
 	}
 	return 0;
 }
-EXPORT_SYMBOL(tcp_connect_offload);
 
 /*
  * TOE capable backlog handler.  This is used for offloaded listening sockets
@@ -91,7 +101,8 @@
  * distinguish TOE from IP packets easily as the former lack network headers.
  * Such TOE packets are fed to a TOE-specific backlog handler.
  */
-static int listen_backlog_rcv(struct sock *sk, struct sk_buff *skb)
+static int
+listen_backlog_rcv(struct socket *so, struct mbuf *m)
 {
 	if (likely(skb->h.raw != skb->nh.raw))
 		return tcp_v4_do_rcv(sk, skb);
@@ -104,41 +115,42 @@
  * We check if the socket should be offloaded according to the current 
  * offloading policies, and if so, publish an OFFLOAD_LISTEN_START event.
  */
-int start_listen_offload(struct sock *sk)
+int
+start_listen_offload(struct socket *so)
 {
 	// IPv4 TCP only for now
-	if (sk->sk_family != PF_INET || sk->sk_protocol != IPPROTO_TCP)
-		return -EPROTONOSUPPORT;
+	if (so->pr_domain->dom_family != AF_INET ||
+	    so->so_proto->pr_protocol != IPPROTO_TCP)
+		return (EPROTONOSUPPORT);
 
 	// filter out loopback listens
 	if (LOOPBACK(inet_sk(sk)->rcv_saddr))
-		return -EADDRNOTAVAIL;
+		return (EADDRNOTAVAIL);
 
 	// Install a TOE capable backlog handler
 	sk->sk_backlog_rcv = listen_backlog_rcv;
 
-	down(&notify_mutex);
+	mtx_lock(&notify_mutex);
 	raw_notifier_call_chain(&listen_offload_notify_list,
 				OFFLOAD_LISTEN_START, sk);
-	up(&notify_mutex);
+	mtx_unlock&notify_mutex);
 	return 0;
 }
-EXPORT_SYMBOL(start_listen_offload);
 
 /*
  * Called when the SW stack is preparing to close an existing listening socket.
  * We publish an OFFLOAD_LISTEN_STOP event.
  */
-int stop_listen_offload(struct sock *sk)
+int
+stop_listen_offload(struct socket *so)
 {
 	if (sk->sk_family != PF_INET || sk->sk_protocol != IPPROTO_TCP)
-		return -EPROTONOSUPPORT;
+		return (EPROTONOSUPPORT);
 
-	down(&notify_mutex);
+	mtx_lock(&notify_mutex);
 	raw_notifier_call_chain(&listen_offload_notify_list,
 				OFFLOAD_LISTEN_STOP, sk);
-	up(&notify_mutex);
+	mtx_unlock&notify_mutex);
 	return 0;
 }
-EXPORT_SYMBOL(stop_listen_offload);
 #endif

==== //depot/projects/opentoe/sys/dev/cxgb/ulp/toecore/toe_offload.h#3 (text+ko) ====

@@ -1,3 +1,35 @@
+
+/**************************************************************************
+
+Copyright (c) 2007, Chelsio Inc.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+    this list of conditions and the following disclaimer.
+
+ 2. Neither the name of the Chelsio Corporation nor the names of its
+    contributors may be used to endorse or promote products derived from
+    this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+$FreeBSD$
+
+***************************************************************************/
+
 #ifndef _NET_OFFLOAD_H
 #define _NET_OFFLOAD_H
 
@@ -16,7 +48,7 @@
 #if 0
 /* Per-skb backlog handler.  Run when a socket's backlog is processed. */
 struct blog_skb_cb {
-	void (*backlog_rcv) (struct sock *sk, struct sk_buff *skb);
+	void (*backlog_rcv) (struct sock *sk, struct mbuf *m);
 	struct toedev *dev;
 };
 

==== //depot/projects/opentoe/sys/dev/cxgb/ulp/toecore/toedev.c#4 (text+ko) ====

@@ -10,11 +10,7 @@
  1. Redistributions of source code must retain the above copyright notice,
     this list of conditions and the following disclaimer.
 
- 2. 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.
-
- 3. Neither the name of the Chelsio Corporation nor the names of its
+ 2. Neither the name of the Chelsio Corporation nor the names of its
     contributors may be used to endorse or promote products derived from
     this software without specific prior written permission.
 
@@ -30,8 +26,10 @@
 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 POSSIBILITY OF SUCH DAMAGE.
 
+***************************************************************************/
 
-***************************************************************************/
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
 
 #include <linux/module.h>
 #include <linux/string.h>
@@ -85,7 +83,7 @@
 {
 	struct tom_info *t;
 
-	list_for_each_entry(t, &offload_module_list, list_node) {
+	TAILQ_FOREACH(&offload_module_list, t, entry) {
 		const struct offload_id *entry;
 
 		entry = id_find(dev->ttid, t->id_table);
@@ -226,11 +224,6 @@
 	return len;
 }
 
-#else
-#define offload_proc_init() 0
-#define offload_proc_cleanup()
-#define create_offload_proc_dir(name) NULL
-#define delete_offload_proc_dir(dev)
 #endif
 
 /**
@@ -270,7 +263,7 @@
 		goto out;
 
 	dev->offload_mod = NULL;
-	list_add_tail(&dev->toe_list, &offload_dev_list);
+	TAILQ_INSERT_TAIL(&offload_dev_list, dev, entry);
 out:
 	mtx_unlock(&offload_db_lock);
 	return ret;
@@ -297,7 +290,7 @@
 		ret = EBUSY;
 		goto out;
 	}
-	TAILQ_REMOVE(&offload_dev_list ,dev, entry);
+	TAILQ_REMOVE(&offload_dev_list, dev, entry);
 out:
 	mtx_unlock(&offload_db_lock);
 	return ret;
@@ -332,28 +325,25 @@
 /**
  * toe_send - send a packet to a TOE device
  * @dev: the device
- * @skb: the packet
+ * @m: the packet
  *
  * Sends an mbuf to a TOE driver after dealing with any active network taps.
  */
-int toe_send(struct toedev *dev, struct mbuf *skb)
+int
+toe_send(struct toedev *dev, struct mbuf *m)
 {
 	int r;
 
-	local_bh_disable();
-	if (unlikely(netdev_nit)) {      /* deal with active taps */
-		skb->nh.raw = skb->data;
-		if (!skb->dev)
-			skb->dev = dev->lldev;
-		dev_queue_xmit_nit(skb, skb->dev);
-	}
-	r = dev->send(dev, skb);
-	local_bh_enable();
+	critical_enter(); /* XXX neccessary? */
+	r = dev->send(dev, m);
+	critical_exit();
+	if (r)
+		BPF_MTAP(dev->lldev, m);
 	return r;
 }
 
 /**
- * toe_receive_skb - process n received TOE packets
+ * toe_receive_mbuf - process n received TOE packets
  * @dev: the toe device
  * @m: an array of offload packets
  * @n: the number of offload packets
@@ -364,15 +354,14 @@
  * it the whole array at once except when there are active taps.
  */
 int
-toe_receive_skb(struct toedev *dev, struct mbuf **m, int n)
+toe_receive_mbuf(struct toedev *dev, struct mbuf **m, int n)
 {
-	if (likely(!netdev_nit))
+	if (likely(!bpf_peers_present(dev->lldev->if_bpf)))
 		return dev->recv(dev, m, n);
 
 	for ( ; n; n--, m++) {
-		m[0]->dev = dev->lldev;
-		dev_queue_xmit_nit(m[0], dev->lldev);
-		m[0]->dev = NULL;
+		m[0]->m_pkthdr.rcvif = dev->lldev;
+		BPF_MTAP(dev->lldev, m[0]);
 		dev->recv(dev, m, 1);
 	}
 	return 0;
@@ -385,15 +374,15 @@
 }
 
 void
-toe_neigh_update(struct rtentry *neigh)
+toe_arp_update(struct rtentry *rt)
 {
-	struct ifnet *dev = neigh->dev;
+	struct ifnet *ifp = rt->rt_ifp;
 
-	if (dev && netdev_is_offload(dev)) {
-		struct toedev *tdev = TOEDEV(dev);
+	if (ifp && netdev_is_offload(ifp)) {
+		struct toedev *tdev = TOEDEV(ifp);
 
-		if (tdev && tdev->neigh_update)
-			tdev->neigh_update(tdev, neigh);
+		if (tdev && tdev->arp_update)
+			tdev->arp_update(tdev, rt);
 	}
 }
 
@@ -473,27 +462,27 @@
 }
 
 static void
-virtual_neigh_update(struct toedev *dev, struct rtentry *neigh)
+virtual_arp_update(struct toedev *dev, struct rtentry *rt)
 {
-	struct ifnet *child = neigh->dev;
-
-	if (neigh->dev->priv_flags & IFF_802_1Q_VLAN)
+	struct ifnet *child = rt->rt_ifp;
+#ifdef notyet
+	if (rt->rt_ifp->if_flags & IFF_802_1Q_VLAN)
 		child = VLAN_DEV_INFO(child)->real_dev;
-
+#endif
 	if (netdev_is_offload(child)) {
 		struct toedev *tdev = TOEDEV(child);
 
 		if (child->flags & IFF_MASTER)
-			toe_bond_neigh_propagate(child, neigh);
+			toe_bond_arp_propagate(child, neigh);
 		else
-			tdev->neigh_update(tdev, neigh);
+			tdev->arp_update(tdev, rt);
 	}
 }
 
 static struct toedev virtual_offload_dev = {
 	.can_offload  = virtual_can_offload,
 	.connect      = virtual_connect,
-	.neigh_update = virtual_neigh_update
+	.arp_update = virtual_arp_update
 };
 
 /*
@@ -517,8 +506,8 @@
 /**
  * toe_enslave - check the enslaving procedure
  * for TOE enabled devices
- * @bond_dev: bonding master net device
- * @slave_dev: device to be enslaved
+ * @bond_ifp: bonding master ifnet
+ * @slave_ifp: ifnet to be enslaved
  *
  * Bonding in TOE context currently has these limitations:
  *	- all slaves must be TOE enabled,
@@ -527,34 +516,34 @@
  *
  */
 int
-toe_enslave(struct ifnet *bond_dev, struct ifnet *slave_dev)
+toe_enslave(struct ifnet *bond_ifp, struct ifnet *slave_ifp)
 {
 	struct toedev *tdev;
 	int slave_count;
 	int ret = 0;
 
-	if (!netdev_is_offload(bond_dev))
+	if (!netdev_is_offload(bond_ifp))
 		return 0;
 
-	if (!is_bmode_supported(bond_dev))
+	if (!is_bmode_supported(bond_ifp))
 		return EOPNOTSUPP;
 
-	tdev = toe_bond_slave_toedev(bond_dev);
-	slave_count = toe_bond_slavecnt(bond_dev);
+	tdev = toe_bond_slave_toedev(bond_ifp);
+	slave_count = toe_bond_slavecnt(bond_ifp);
 
 	/* First slave */
 	if ((slave_count == 1) && (netdev_is_offload(slave_dev))) {
 		/* Device is TOE enabled, bonding mode is supported */
-		TOEDEV(bond_dev) = &virtual_offload_dev;
+		TOEDEV(bond_ifp) = &virtual_offload_dev;
 		bond_dev->hard_header_len = slave_dev->hard_header_len;
 	}
 
 	/* Mix of TOE enabled and regular devices not supported */
-	else if (netdev_is_offload(bond_dev) ^ netdev_is_offload(slave_dev))
+	else if (netdev_is_offload(bond_ifp) ^ netdev_is_offload(slave_ifp))
 		ret = EOPNOTSUPP;
 
 	/* TOE enabled device belongs to another adapter */
-	else if (tdev != TOEDEV(slave_dev))
+	else if (tdev != TOEDEV(slave_ifp))
 		ret = EOPNOTSUPP;
 
 	return ret;
@@ -562,21 +551,21 @@
 
 /**
  * toe_failover - executes failover for offloaded connections
- * @bond_dev: bonding master net device
- * @dev: slave device triggering the failover event
+ * @bond_ifp: bonding master net device
+ * @ifp: slave device triggering the failover event
  * @event: change of active slave, or 802.3ad port down|up
  *
  * Called under bond driver locks.
  */
 
 void
-toe_failover(struct ifnet *bond_dev, struct ifnet *dev, int event)
+toe_failover(struct ifnet *bond_ifp, struct ifnet *ifp, int event)
 {
-	if (netdev_is_offload(bond_dev)) {
-			struct toedev *tdev = toe_bond_slave_toedev(bond_dev);
-			
-			if (tdev)
-				tdev->failover(tdev, bond_dev, dev, event);
+	if (netdev_is_offload(bond_ifp)) {
+		struct toedev *tdev = toe_bond_slave_toedev(bond_ifp);
+		
+		if (tdev)
+			tdev->failover(tdev, bond_ifp, dev, event);
 	}
 }
 
@@ -587,10 +576,6 @@
 static int
 offload_init(void)
 {
-	/* We tolerate proc failures */
-	if (offload_proc_init())
-		printk(KERN_WARNING "Unable to create /proc/net/offload\n");
-
 	/* We tolerate notifier registration failures */
 	if (register_netdevice_notifier(&virt_dev_notifier) < 0)
 		printk(KERN_WARNING

==== //depot/projects/opentoe/sys/dev/cxgb/ulp/toecore/toedev.h#3 (text+ko) ====

@@ -10,11 +10,7 @@
  1. Redistributions of source code must retain the above copyright notice,
     this list of conditions and the following disclaimer.
 
- 2. 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.
-
- 3. Neither the name of the Chelsio Corporation nor the names of its
+ 2. Neither the name of the Chelsio Corporation nor the names of its
     contributors may be used to endorse or promote products derived from
     this software without specific prior written permission.
 
@@ -33,6 +29,7 @@
 $FreeBSD$
 
 ***************************************************************************/
+
 #ifndef _OFFLOAD_DEV_H_
 #define _OFFLOAD_DEV_H_
 
@@ -103,12 +100,12 @@
 	int (*close)(struct toedev *dev);
 	int (*can_offload)(struct toedev *dev, struct socket *so);
 	int (*connect)(struct toedev *dev, struct socket *so,
-		       struct ifnet *egress_dev);
-	int (*send)(struct toedev *dev, struct mbuf *skb);
-	int (*recv)(struct toedev *dev, struct mbuf **skb, int n);
+		       struct ifnet *egress_ifp);
+	int (*send)(struct toedev *dev, struct mbuf *m);
+	int (*recv)(struct toedev *dev, struct mbuf **m, int n);
 	int (*ctl)(struct toedev *dev, unsigned int req, void *data);
 	void (*neigh_update)(struct toedev *dev, struct rtentry *neigh);
-	void (*failover)(struct toedev *dev, struct ifnet *bond_dev,
+	void (*failover)(struct toedev *dev, struct ifnet *bond_ifp,
 			 struct ifnet *ndev, int event);
 	void *priv;                 /* driver private data */
 	void *l2opt;                /* optional layer 2 data */
@@ -135,38 +132,38 @@
 extern int register_toedev(struct toedev *dev, const char *name);
 extern int unregister_toedev(struct toedev *dev);
 extern int activate_offload(struct toedev *dev);
-extern int toe_send(struct toedev *dev, struct mbuf *skb);
+extern int toe_send(struct toedev *dev, struct mbuf *m);
 extern struct ifnet *offload_get_phys_egress(struct ifnet *dev,
 						  struct socket *so,
 						  int context);
 
 #if defined(CONFIG_TCP_OFFLOAD_MODULE)
-static inline int toe_receive_skb(struct toedev *dev, struct mbuf **skb,
+static inline int toe_receive_mbuf(struct toedev *dev, struct mbuf **m,
 				  int n)
 {
-	return dev->recv(dev, skb, n);
+	return dev->recv(dev, m, n);
 }
 
 extern int  prepare_tcp_for_offload(void);
 extern void restore_tcp_to_nonoffload(void);
 #elif defined(CONFIG_TCP_OFFLOAD)
-extern int toe_receive_skb(struct toedev *dev, struct mbuf **skb, int n);
+extern int toe_receive_mbuf(struct toedev *dev, struct mbuf **m, int n);
 #endif
 
 #if defined(CONFIG_TCP_OFFLOAD) || \
     (defined(CONFIG_TCP_OFFLOAD_MODULE) && defined(MODULE))
 extern void toe_neigh_update(struct rtentry *neigh);
-extern void toe_failover(struct ifnet *bond_dev,
-			 struct ifnet *fail_dev, int event);
-extern int toe_enslave(struct ifnet *bond_dev,
-		       struct ifnet *slave_dev);
+extern void toe_failover(struct ifnet *bond_ifp,
+			 struct ifnet *fail_ifp, int event);
+extern int toe_enslave(struct ifnet *bond_ifp,
+		       struct ifnet *slave_ifp);
 #else
 static inline void toe_neigh_update(struct ifnet *neigh) {}
-static inline void toe_failover(struct ifnet *bond_dev,
-				struct ifnet *fail_dev, int event)
+static inline void toe_failover(struct ifnet *bond_ifp,
+				struct ifnet *fail_ifp, int event)
 {}
-static inline int toe_enslave(struct ifnet *bond_dev,
-			      struct ifnet *slave_dev)
+static inline int toe_enslave(struct ifnet *bond_ifp,
+			      struct ifnet *slave_ifp)
 {
 	return 0;
 }


More information about the p4-projects mailing list