PERFORCE change 116075 for review
Kip Macy
kmacy at FreeBSD.org
Sun Mar 18 06:33:58 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=116075
Change 116075 by kmacy at kmacy_vt-x:opentoe_init on 2007/03/18 06:33:10
- fix copyrights
- fix includes
- fix API usage to something closer to what would work on FreeBSD
- fix style
Affected files ...
.. //depot/projects/opentoe/sys/dev/cxgb/cxgb_offload.c#2 edit
Differences ...
==== //depot/projects/opentoe/sys/dev/cxgb/cxgb_offload.c#2 (text+ko) ====
@@ -1,71 +1,86 @@
-/*
- * Copyright (c) 2006 Chelsio, Inc. All rights reserved.
- * Copyright (c) 2006 Open Grid Computing, Inc. 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
- * OpenIB.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.
- */
+
+/**************************************************************************
+
+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. 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
+ 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: src/sys/dev/cxgb/cxgb_main.c,v 1.3 2007/03/14 07:57:59 kmacy Exp $");
-#include <linux/list.h>
-#include <net/neighbour.h>
-#include <linux/notifier.h>
-#include <asm/atomic.h>
-#include <linux/proc_fs.h>
-#include <linux/if_vlan.h>
-#include <linux/vmalloc.h>
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/module.h>
+#include <sys/pciio.h>
+#include <sys/conf.h>
+#include <machine/bus.h>
+#include <machine/resource.h>
+#include <sys/bus_dma.h>
+#include <sys/rman.h>
+#include <sys/ioccom.h>
+#include <sys/mbuf.h>
+#include <sys/linker.h>
+#include <sys/firmware.h>
+#include <sys/socket.h>
+#include <sys/sockio.h>
+#include <sys/smp.h>
+#include <sys/sysctl.h>
+#include <sys/queue.h>
+#include <sys/taskqueue.h>
-#include "common.h"
-#include "regs.h"
-#include "cxgb3_ioctl.h"
-#include "cxgb3_ctl_defs.h"
-#include "cxgb3_defs.h"
-#include "l2t.h"
-#include "firmware_exports.h"
-#include "cxgb3_offload.h"
+#include <dev/cxgb/cxgb_osdep.h>
+#include <dev/cxgb/common/cxgb_common.h>
+#include <dev/cxgb/cxgb_ioctl.h>
+#include <dev/cxgb/common/cxgb_regs.h>
+#include <dev/cxgb/common/cxgb_t3_cpl.h>
+#include <dev/cxgb/common/cxgb_firmware_exports.h>
-#include "cxgb3_compat.h"
-#if defined(NETEVENT)
-#include <net/netevent.h>
-#endif
static LIST_HEAD(client_list);
static LIST_HEAD(ofld_dev_list);
-static DEFINE_MUTEX(cxgb3_db_lock);
+static LIST_HEAD(adapter_list);
+
+static struct mtx cxgb_db_lock;
+static struct rwlock adapter_list_lock;
-static DEFINE_RWLOCK(adapter_list_lock);
-static LIST_HEAD(adapter_list);
static const unsigned int MAX_ATIDS = 64 * 1024;
static const unsigned int ATID_BASE = 0x100000;
-static struct proc_dir_entry *cxgb3_proc_root;
-static inline int offload_activated(struct t3cdev *tdev)
+static inline int
+offload_activated(struct toedev *tdev)
{
struct adapter *adapter = tdev2adap(tdev);
@@ -73,110 +88,114 @@
}
/**
- * cxgb3_register_client - register an offload client
+ * cxgb_register_client - register an offload client
* @client: the client
*
* Add the client to the client list,
* and call backs the client for each activated offload device
*/
-void cxgb3_register_client(struct cxgb3_client *client)
+void
+cxgb_register_client(struct cxgb_client *client)
{
- struct t3cdev *tdev;
+ struct toedev *tdev;
- mutex_lock(&cxgb3_db_lock);
- list_add_tail(&client->client_list, &client_list);
+ mtx_lock(&cxgb_db_lock);
+ TAILQ_INSERT_TAIL(&client->client_list, client, client_entry);
if (client->add) {
- list_for_each_entry(tdev, &ofld_dev_list, ofld_dev_list) {
+ TAILQ_FOREACH(tdev, &ofld_dev_list, ofld_entry) {
if (offload_activated(tdev))
client->add(tdev);
}
}
- mutex_unlock(&cxgb3_db_lock);
+ mtx_unlock(&cxgb_db_lock);
}
-EXPORT_SYMBOL(cxgb3_register_client);
+
/**
- * cxgb3_unregister_client - unregister an offload client
+ * cxgb_unregister_client - unregister an offload client
* @client: the client
*
* Remove the client to the client list,
* and call backs the client for each activated offload device.
*/
-void cxgb3_unregister_client(struct cxgb3_client *client)
+void
+cxgb_unregister_client(struct cxgb_client *client)
{
- struct t3cdev *tdev;
+ struct toedev *tdev;
- mutex_lock(&cxgb3_db_lock);
- list_del(&client->client_list);
+ mtx_lock(&cxgb_db_lock);
+ TAILQ_REMOVE(&client->client_list, client, client_entry);
if (client->remove) {
- list_for_each_entry(tdev, &ofld_dev_list, ofld_dev_list) {
+ TAILQ_FOREACH(tdev, &ofld_dev_list, ofld_entry) {
if (offload_activated(tdev))
client->remove(tdev);
}
}
- mutex_unlock(&cxgb3_db_lock);
+ mtx_unlock(&cxgb_db_lock);
}
-EXPORT_SYMBOL(cxgb3_unregister_client);
/**
- * cxgb3_add_clients - activate register clients for an offload device
+ * cxgb_add_clients - activate register clients for an offload device
* @tdev: the offload device
*
* Call backs all registered clients once a offload device is activated
*/
-void cxgb3_add_clients(struct t3cdev *tdev)
+void
+cxgb_add_clients(struct toedev *tdev)
{
- struct cxgb3_client *client;
+ struct cxgb_client *client;
- mutex_lock(&cxgb3_db_lock);
- list_for_each_entry(client, &client_list, client_list) {
+ mtx_lock(&cxgb_db_lock);
+ TAILQ_FOREACH(client, &client_list, client_entry) {
if (client->add)
client->add(tdev);
}
- mutex_unlock(&cxgb3_db_lock);
+ mtx_unlock(&cxgb_db_lock);
}
/**
- * cxgb3_remove_clients - activate register clients for an offload device
+ * cxgb_remove_clients - activate register clients for an offload device
* @tdev: the offload device
*
* Call backs all registered clients once a offload device is deactivated
*/
-void cxgb3_remove_clients(struct t3cdev *tdev)
+void
+cxgb_remove_clients(struct toedev *tdev)
{
- struct cxgb3_client *client;
+ struct cxgb_client *client;
- mutex_lock(&cxgb3_db_lock);
- list_for_each_entry(client, &client_list, client_list) {
+ mtx_lock(&cxgb_db_lock);
+ TAILQ_FOREACH(client, &client_list, client_entry) {
if (client->remove)
client->remove(tdev);
}
- mutex_unlock(&cxgb3_db_lock);
+ mtx_unlock(&cxgb_db_lock);
}
-static int is_offloading(struct net_device *dev)
+static int
+is_offloading(struct ifnet *ifp)
{
struct adapter *adapter;
int port;
- read_lock_bh(&adapter_list_lock);
- list_for_each_entry(adapter, &adapter_list, adapter_list) {
+ rw_rlock(&adapter_list_lock);
+
+ TAILQ_FOREACH(adapter, &adapter_list, adapter_entry) {
for_each_port(adapter, port) {
if (dev == adapter->port[port].dev) {
- read_unlock_bh(&adapter_list_lock);
+ rw_runlock(&adapter_list_lock);
return 1;
}
}
}
- read_unlock_bh(&adapter_list_lock);
+ rw_runlock(&adapter_list_lock);
return 0;
}
-static struct net_device *get_iff_from_mac(adapter_t *adapter,
- const unsigned char *mac,
- unsigned int vlan)
+static struct net_device *
+get_iff_from_mac(adapter_t *adapter, const uint8_t *mac, unsigned int vlan)
{
int i;
@@ -198,7 +217,8 @@
return NULL;
}
-static inline void failover_fixup(adapter_t *adapter, int port)
+static inline void
+failover_fixup(adapter_t *adapter, int port)
{
if (adapter->params.rev == 0) {
struct net_device *dev = adapter->port[port].dev;
@@ -218,7 +238,8 @@
}
}
-static int cxgb_ulp_iscsi_ctl(adapter_t *adapter, unsigned int req, void *data)
+static int
+cxgb_ulp_iscsi_ctl(adapter_t *adapter, unsigned int req, void *data)
{
int ret = 0;
struct ulp_iscsi_info *uiip = data;
@@ -255,7 +276,8 @@
/* Response queue used for RDMA events. */
#define ASYNC_NOTIF_RSPQ 0
-static int cxgb_rdma_ctl(adapter_t *adapter, unsigned int req, void *data)
+static int
+cxgb_rdma_ctl(adapter_t *adapter, unsigned int req, void *data)
{
int ret = 0;
@@ -340,7 +362,8 @@
return ret;
}
-static int cxgb_offload_ctl(struct t3cdev *tdev, unsigned int req, void *data)
+static int
+cxgb_offload_ctl(struct toedev *tdev, unsigned int req, void *data)
{
struct adapter *adapter = tdev2adap(tdev);
struct tid_range *tid;
@@ -438,21 +461,23 @@
* proper processing is setup. This complains and drops the packet as it isn't
* normal to get offload packets at this stage.
*/
-static int rx_offload_blackhole(struct t3cdev *dev, struct sk_buff **skbs,
- int n)
+static int
+rx_offload_blackhole(struct toedev *dev, struct mbuf **m, int n)
{
CH_ERR(tdev2adap(dev), "%d unexpected offload packets, first data %u\n",
- n, ntohl(*(u32 *)skbs[0]->data));
+ n, ntohl(*(u32 *)m[0]->data));
while (n--)
- dev_kfree_skb_any(skbs[n]);
+ m_freem(m[n]);
return 0;
}
-static void dummy_neigh_update(struct t3cdev *dev, struct neighbour *neigh)
+static void
+dummy_neigh_update(struct toedev *dev, struct neighbour *neigh)
{
}
-void cxgb3_set_dummy_ops(struct t3cdev *dev)
+void
+cxgb_set_dummy_ops(struct toedev *dev)
{
dev->recv = rx_offload_blackhole;
dev->neigh_update = dummy_neigh_update;
@@ -461,39 +486,40 @@
/*
* Free an active-open TID.
*/
-void *cxgb3_free_atid(struct t3cdev *tdev, int atid)
+void *
+cxgb_free_atid(struct toedev *tdev, int atid)
{
struct tid_info *t = &(T3C_DATA(tdev))->tid_maps;
union active_open_entry *p = atid2entry(t, atid);
void *ctx = p->t3c_tid.ctx;
- spin_lock_bh(&t->atid_lock);
+ mtx_lock(&t->atid_lock);
p->next = t->afree;
t->afree = p;
t->atids_in_use--;
- spin_unlock_bh(&t->atid_lock);
+ mtx_lock(&t->atid_lock);
return ctx;
}
-EXPORT_SYMBOL(cxgb3_free_atid);
/*
* Free a server TID and return it to the free pool.
*/
-void cxgb3_free_stid(struct t3cdev *tdev, int stid)
+void
+cxgb_free_stid(struct toedev *tdev, int stid)
{
struct tid_info *t = &(T3C_DATA(tdev))->tid_maps;
union listen_entry *p = stid2entry(t, stid);
- spin_lock_bh(&t->stid_lock);
+ mtx_lock(&t->stid_lock);
p->next = t->sfree;
t->sfree = p;
t->stids_in_use--;
- spin_unlock_bh(&t->stid_lock);
+ mtx_unlock(&t->stid_lock);
}
-EXPORT_SYMBOL(cxgb3_free_stid);
-void cxgb3_insert_tid(struct t3cdev *tdev, struct cxgb3_client *client,
+void
+cxgb_insert_tid(struct toedev *tdev, struct cxgb_client *client,
void *ctx, unsigned int tid)
{
struct tid_info *t = &(T3C_DATA(tdev))->tid_maps;
@@ -502,12 +528,12 @@
t->tid_tab[tid].ctx = ctx;
atomic_inc(&t->tids_in_use);
}
-EXPORT_SYMBOL(cxgb3_insert_tid);
/*
* Populate a TID_RELEASE WR. The skb must be already propely sized.
*/
-static inline void mk_tid_release(struct sk_buff *skb, unsigned int tid)
+static inline void
+mk_tid_release(struct mbuf *m, unsigned int tid)
{
struct cpl_tid_release *req;
@@ -517,43 +543,44 @@
OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_TID_RELEASE, tid));
}
-static void t3_process_tid_release_list(void *data)
+static void
+t3_process_tid_release_list(void *data)
{
- struct sk_buff *skb;
- struct t3cdev *tdev = data;
+ struct mbuf *m;
+ struct toedev *tdev = data;
struct t3c_data *td = T3C_DATA(tdev);
- spin_lock_bh(&td->tid_release_lock);
+ mtx_lock(&td->tid_release_lock);
while (td->tid_release_list) {
struct t3c_tid_entry *p = td->tid_release_list;
td->tid_release_list = (struct t3c_tid_entry *)p->ctx;
- spin_unlock_bh(&td->tid_release_lock);
+ mtx_unlock(&td->tid_release_lock);
skb = alloc_skb(sizeof(struct cpl_tid_release),
GFP_KERNEL | __GFP_NOFAIL);
mk_tid_release(skb, p - td->tid_maps.tid_tab);
- cxgb3_ofld_send(tdev, skb);
+ cxgb_ofld_send(tdev, skb);
p->ctx = NULL;
- spin_lock_bh(&td->tid_release_lock);
+ mtx_lock(&td->tid_release_lock);
}
- spin_unlock_bh(&td->tid_release_lock);
+ mtx_unlock(&td->tid_release_lock);
}
/* use ctx as a next pointer in the tid release list */
-void cxgb3_queue_tid_release(struct t3cdev *tdev, unsigned int tid)
+void
+cxgb_queue_tid_release(struct toedev *tdev, unsigned int tid)
{
struct t3c_data *td = T3C_DATA(tdev);
struct t3c_tid_entry *p = &td->tid_maps.tid_tab[tid];
- spin_lock_bh(&td->tid_release_lock);
+ mtx_lock(&td->tid_release_lock);
p->ctx = (void *)td->tid_release_list;
td->tid_release_list = p;
if (!p->ctx)
schedule_work(&td->tid_release_task);
- spin_unlock_bh(&td->tid_release_lock);
+ mtx_unlock(&td->tid_release_lock);
}
-EXPORT_SYMBOL(cxgb3_queue_tid_release);
/*
* Remove a tid from the TID table. A client may defer processing its last
@@ -562,7 +589,8 @@
* To handle this we atomically switch the TID association if it still points
* to the original client context.
*/
-void cxgb3_remove_tid(struct t3cdev *tdev, void *ctx, unsigned int tid)
+void
+cxgb_remove_tid(struct toedev *tdev, void *ctx, unsigned int tid)
{
struct tid_info *t = &(T3C_DATA(tdev))->tid_maps;
@@ -570,27 +598,27 @@
if (tdev->type == T3A)
(void)cmpxchg(&t->tid_tab[tid].ctx, ctx, NULL);
else {
- struct sk_buff *skb;
+ struct mbuf *m;
skb = alloc_skb(sizeof(struct cpl_tid_release), GFP_ATOMIC);
if (likely(skb)) {
mk_tid_release(skb, tid);
- cxgb3_ofld_send(tdev, skb);
+ cxgb_ofld_send(tdev, skb);
t->tid_tab[tid].ctx = NULL;
} else
- cxgb3_queue_tid_release(tdev, tid);
+ cxgb_queue_tid_release(tdev, tid);
}
atomic_dec(&t->tids_in_use);
}
-EXPORT_SYMBOL(cxgb3_remove_tid);
-int cxgb3_alloc_atid(struct t3cdev *tdev, struct cxgb3_client *client,
+int
+cxgb_alloc_atid(struct toedev *tdev, struct cxgb_client *client,
void *ctx)
{
int atid = -1;
struct tid_info *t = &(T3C_DATA(tdev))->tid_maps;
- spin_lock_bh(&t->atid_lock);
+ mtx_lock(&t->atid_lock);
if (t->afree) {
union active_open_entry *p = t->afree;
@@ -600,18 +628,18 @@
p->t3c_tid.client = client;
t->atids_in_use++;
}
- spin_unlock_bh(&t->atid_lock);
+ mtx_unlock(&t->atid_lock);
return atid;
}
-EXPORT_SYMBOL(cxgb3_alloc_atid);
-int cxgb3_alloc_stid(struct t3cdev *tdev, struct cxgb3_client *client,
+int
+cxgb_alloc_stid(struct toedev *tdev, struct cxgb_client *client,
void *ctx)
{
int stid = -1;
struct tid_info *t = &(T3C_DATA(tdev))->tid_maps;
- spin_lock_bh(&t->stid_lock);
+ mtx_lock(&t->stid_lock);
if (t->sfree) {
union listen_entry *p = t->sfree;
@@ -621,36 +649,38 @@
p->t3c_tid.client = client;
t->stids_in_use++;
}
- spin_unlock_bh(&t->stid_lock);
+ mtx_unlock(&t->stid_lock);
return stid;
}
-EXPORT_SYMBOL(cxgb3_alloc_stid);
-static int do_smt_write_rpl(struct t3cdev *dev, struct sk_buff *skb)
+static int
+do_smt_write_rpl(struct toedev *dev, struct mbuf *m)
{
struct cpl_smt_write_rpl *rpl = cplhdr(skb);
if (rpl->status != CPL_ERR_NONE)
- printk(KERN_ERR
+ log(LOG_ERR,
"Unexpected SMT_WRITE_RPL status %u for entry %u\n",
rpl->status, GET_TID(rpl));
return CPL_RET_BUF_DONE;
}
-static int do_l2t_write_rpl(struct t3cdev *dev, struct sk_buff *skb)
+static int
+do_l2t_write_rpl(struct toedev *dev, struct mbuf *m)
{
struct cpl_l2t_write_rpl *rpl = cplhdr(skb);
if (rpl->status != CPL_ERR_NONE)
- printk(KERN_ERR
+ log(LOG_ERR,
"Unexpected L2T_WRITE_RPL status %u for entry %u\n",
rpl->status, GET_TID(rpl));
return CPL_RET_BUF_DONE;
}
-static int do_act_open_rpl(struct t3cdev *dev, struct sk_buff *skb)
+static int
+do_act_open_rpl(struct toedev *dev, struct mbuf *m)
{
struct cpl_act_open_rpl *rpl = cplhdr(skb);
unsigned int atid = G_TID(ntohl(rpl->atid));
@@ -662,13 +692,14 @@
return t3c_tid->client->handlers[CPL_ACT_OPEN_RPL] (dev, skb,
t3c_tid->ctx);
} else {
- printk(KERN_ERR "%s: received clientless CPL command 0x%x\n",
+ log(LOG_ERR, "%s: received clientless CPL command 0x%x\n",
dev->name, CPL_ACT_OPEN_RPL);
return CPL_RET_BUF_DONE | CPL_RET_BAD_MSG;
}
}
-static int do_stid_rpl(struct t3cdev *dev, struct sk_buff *skb)
+static int
+do_stid_rpl(struct toedev *dev, struct mbuf *m)
{
union opcode_tid *p = cplhdr(skb);
unsigned int stid = G_TID(ntohl(p->opcode_tid));
@@ -679,13 +710,14 @@
t3c_tid->client->handlers[p->opcode]) {
return t3c_tid->client->handlers[p->opcode] (dev, skb, t3c_tid->ctx);
} else {
- printk(KERN_ERR "%s: received clientless CPL command 0x%x\n",
+ log(LOG_ERR, "%s: received clientless CPL command 0x%x\n",
dev->name, p->opcode);
return CPL_RET_BUF_DONE | CPL_RET_BAD_MSG;
}
}
-static int do_hwtid_rpl(struct t3cdev *dev, struct sk_buff *skb)
+static int
+do_hwtid_rpl(struct toedev *dev, struct mbuf *m)
{
union opcode_tid *p = cplhdr(skb);
unsigned int hwtid = G_TID(ntohl(p->opcode_tid));
@@ -697,13 +729,14 @@
return t3c_tid->client->handlers[p->opcode]
(dev, skb, t3c_tid->ctx);
} else {
- printk(KERN_ERR "%s: received clientless CPL command 0x%x\n",
+ log(LOG_ERR, "%s: received clientless CPL command 0x%x\n",
dev->name, p->opcode);
return CPL_RET_BUF_DONE | CPL_RET_BAD_MSG;
}
}
-static int do_cr(struct t3cdev *dev, struct sk_buff *skb)
+static int
+do_cr(struct toedev *dev, struct mbuf *m)
{
struct cpl_pass_accept_req *req = cplhdr(skb);
unsigned int stid = G_PASS_OPEN_TID(ntohl(req->tos_tid));
@@ -715,13 +748,14 @@
return t3c_tid->client->handlers[CPL_PASS_ACCEPT_REQ]
(dev, skb, t3c_tid->ctx);
} else {
- printk(KERN_ERR "%s: received clientless CPL command 0x%x\n",
+ log(LOG_ERR, "%s: received clientless CPL command 0x%x\n",
dev->name, CPL_PASS_ACCEPT_REQ);
return CPL_RET_BUF_DONE | CPL_RET_BAD_MSG;
}
}
-static int do_abort_req_rss(struct t3cdev *dev, struct sk_buff *skb)
+static int
+do_abort_req_rss(struct toedev *dev, struct mbuf *m)
{
union opcode_tid *p = cplhdr(skb);
unsigned int hwtid = G_TID(ntohl(p->opcode_tid));
@@ -736,10 +770,10 @@
struct cpl_abort_req_rss *req = cplhdr(skb);
struct cpl_abort_rpl *rpl;
- struct sk_buff *skb =
+ struct mbuf *m =
alloc_skb(sizeof(struct cpl_abort_rpl), GFP_ATOMIC);
if (!skb) {
- printk("do_abort_req_rss: couldn't get skb!\n");
+ log(LOG_NOTICE, "do_abort_req_rss: couldn't get skb!\n");
goto out;
}
skb->priority = CPL_PRIORITY_DATA;
@@ -751,13 +785,14 @@
OPCODE_TID(rpl) =
htonl(MK_OPCODE_TID(CPL_ABORT_RPL, GET_TID(req)));
rpl->cmd = req->status;
- cxgb3_ofld_send(dev, skb);
+ cxgb_ofld_send(dev, skb);
out:
return CPL_RET_BUF_DONE;
}
}
-static int do_act_establish(struct t3cdev *dev, struct sk_buff *skb)
+static int
+do_act_establish(struct toedev *dev, struct mbuf *m)
{
struct cpl_act_establish *req = cplhdr(skb);
unsigned int atid = G_PASS_OPEN_TID(ntohl(req->tos_tid));
@@ -769,24 +804,26 @@
return t3c_tid->client->handlers[CPL_ACT_ESTABLISH]
(dev, skb, t3c_tid->ctx);
} else {
- printk(KERN_ERR "%s: received clientless CPL command 0x%x\n",
+ log(LOG_ERR, "%s: received clientless CPL command 0x%x\n",
dev->name, CPL_PASS_ACCEPT_REQ);
return CPL_RET_BUF_DONE | CPL_RET_BAD_MSG;
}
}
-static int do_set_tcb_rpl(struct t3cdev *dev, struct sk_buff *skb)
+static int
+do_set_tcb_rpl(struct toedev *dev, struct mbuf *m)
{
struct cpl_set_tcb_rpl *rpl = cplhdr(skb);
if (rpl->status != CPL_ERR_NONE)
- printk(KERN_ERR
- "Unexpected SET_TCB_RPL status %u for tid %u\n",
+ log(LOG_ERR,
+ "Unexpected SET_TCB_RPL status %u for tid %u\n",
rpl->status, GET_TID(rpl));
return CPL_RET_BUF_DONE;
}
-static int do_trace(struct t3cdev *dev, struct sk_buff *skb)
+static int
+do_trace(struct toedev *dev, struct mbuf *m)
{
struct cpl_trace_pkt *p = cplhdr(skb);
@@ -798,7 +835,8 @@
return 0;
}
-static int do_term(struct t3cdev *dev, struct sk_buff *skb)
+static int
+do_term(struct toedev *dev, struct mbuf *m)
{
unsigned int hwtid = ntohl(skb->priority) >> 8 & 0xfffff;
unsigned int opcode = G_OPCODE(ntohl(skb->csum));
@@ -809,45 +847,12 @@
t3c_tid->client->handlers[opcode]) {
return t3c_tid->client->handlers[opcode](dev,skb,t3c_tid->ctx);
} else {
- printk(KERN_ERR "%s: received clientless CPL command 0x%x\n",
+ log(LOG_ERR, "%s: received clientless CPL command 0x%x\n",
dev->name, opcode);
return CPL_RET_BUF_DONE | CPL_RET_BAD_MSG;
}
}
-#if defined(NETEVENT)
-static int nb_callback(struct notifier_block *self, unsigned long event,
- void *ctx)
-{
- switch (event) {
- case (NETEVENT_NEIGH_UPDATE): {
- cxgb_neigh_update((struct neighbour *)ctx);
- break;
- }
-#ifdef DIVY /* XXX Divy no NETEVENT_ROUTE_UPDATE definition */
- case (NETEVENT_ROUTE_UPDATE):
- break;
-#endif
- case (NETEVENT_PMTU_UPDATE):
- break;
- case (NETEVENT_REDIRECT): {
- struct netevent_redirect *nr = ctx;
- cxgb_redirect(nr->old, nr->new);
- cxgb_neigh_update(nr->new->neighbour);
- break;
- }
- default:
- break;
- }
- return 0;
-}
-#else
-static int nb_callback(struct notifier_block *self, unsigned long event,
- void *ctx)
-{
- return 0;
-}
-
#if defined (CONFIG_CHELSIO_T3_MODULE)
#include <linux/config.h>
#include <linux/kallsyms.h>
@@ -856,7 +861,8 @@
static int (*orig_arp_constructor)(struct neighbour *);
-static void neigh_suspect(struct neighbour *neigh)
+static void
+neigh_suspect(struct neighbour *neigh)
{
struct hh_cache *hh;
@@ -866,7 +872,8 @@
hh->hh_output = neigh->ops->output;
}
-static void neigh_connect(struct neighbour *neigh)
+static void
+neigh_connect(struct neighbour *neigh)
{
struct hh_cache *hh;
@@ -876,7 +883,8 @@
hh->hh_output = neigh->ops->hh_output;
}
-static inline int neigh_max_probes(const struct neighbour *n)
+static inline int
+neigh_max_probes(const struct neighbour *n)
{
const struct neigh_parms *p = n->parms;
return (n->nud_state & NUD_PROBE ?
@@ -884,7 +892,8 @@
p->ucast_probes + p->app_probes + p->mcast_probes);
}
-static void neigh_timer_handler_offload(unsigned long arg)
+static void
+neigh_timer_handler_offload(unsigned long arg)
{
unsigned long now, next;
struct neighbour *neigh = (struct neighbour *)arg;
@@ -899,7 +908,7 @@
if (!(state & NUD_IN_TIMER)) {
#ifndef CONFIG_SMP
- printk(KERN_WARNING "neigh: timer & !nud_in_timer\n");
+ log(LOG_WARNING, "neigh: timer & !nud_in_timer\n");
#endif
goto out;
}
@@ -944,7 +953,7 @@
if ((neigh->nud_state & (NUD_INCOMPLETE | NUD_PROBE)) &&
atomic_read(&neigh->probes) >= neigh_max_probes(neigh)) {
- struct sk_buff *skb;
+ struct mbuf *m;
neigh->nud_state = NUD_FAILED;
neigh->updated = jiffies;
@@ -973,7 +982,7 @@
neigh_hold(neigh);
}
if (neigh->nud_state & (NUD_INCOMPLETE | NUD_PROBE)) {
- struct sk_buff *skb = skb_peek(&neigh->arp_queue);
+ struct mbuf *m = skb_peek(&neigh->arp_queue);
/* keep skb alive even if arp_queue overflows */
if (skb)
skb_get(skb);
@@ -994,7 +1003,8 @@
neigh_release(neigh);
}
-static int arp_constructor_offload(struct neighbour *neigh)
+static int
+arp_constructor_offload(struct neighbour *neigh)
{
if (neigh->dev && is_offloading(neigh->dev))
neigh->timer.function = neigh_timer_handler_offload;
@@ -1005,7 +1015,8 @@
* This must match exactly the signature of neigh_update for jprobes to work.
* It runs from a trap handler with interrupts off so don't disable BH.
*/
-static int neigh_update_offload(struct neighbour *neigh, const u8 *lladdr,
+static int
+neigh_update_offload(struct neighbour *neigh, const u8 *lladdr,
u8 new, u32 flags)
{
write_lock(&neigh->lock);
@@ -1021,13 +1032,15 @@
.kp.addr = (kprobe_opcode_t *) neigh_update
};
-static int prepare_arp_with_t3core(void)
+#ifdef MODULE_SUPPORT
+static int
+prepare_arp_with_t3core(void)
{
int err;
err = register_jprobe(&neigh_update_jprobe);
if (err) {
- printk(KERN_ERR "Could not install neigh_update jprobe, "
+ log(LOG_ERR, "Could not install neigh_update jprobe, "
"error %d\n", err);
return err;
}
@@ -1038,35 +1051,34 @@
return 0;
}
-static void restore_arp_sans_t3core(void)
+static void
+restore_arp_sans_t3core(void)
{
arp_tbl.constructor = orig_arp_constructor;
unregister_jprobe(&neigh_update_jprobe);
}
#else /* Module suport */
-static inline int prepare_arp_with_t3core(void)
+static inline int
+prepare_arp_with_t3core(void)
{
return 0;
}
-static inline void restore_arp_sans_t3core(void)
+static inline void
+restore_arp_sans_t3core(void)
{}
+
#endif
-#endif /* netevent */
-
-static struct notifier_block nb = {
- .notifier_call = nb_callback
-};
-
/*
* Process a received packet with an unknown/unexpected CPL opcode.
*/
-static int do_bad_cpl(struct t3cdev *dev, struct sk_buff *skb)
+static int
+do_bad_cpl(struct toedev *dev, struct mbuf *m)
{
- printk(KERN_ERR "%s: received bad CPL command 0x%x\n", dev->name,
- *skb->data);
- return CPL_RET_BUF_DONE | CPL_RET_BAD_MSG;
+ log(LOG_ERR, "%s: received bad CPL command 0x%x\n", dev->name,
+ *m->m_data);
+ return (CPL_RET_BUF_DONE | CPL_RET_BAD_MSG);
}
/*
@@ -1078,37 +1090,38 @@
* Add a new handler to the CPL dispatch table. A NULL handler may be supplied
* to unregister an existing handler.
*/
-void t3_register_cpl_handler(unsigned int opcode, cpl_handler_func h)
+void
+t3_register_cpl_handler(unsigned int opcode, cpl_handler_func h)
{
if (opcode < NUM_CPL_CMDS)
cpl_handlers[opcode] = h ? h : do_bad_cpl;
else
- printk(KERN_ERR "T3C: handler registration for "
+ log(LOG_ERR, "T3C: handler registration for "
"opcode %x failed\n", opcode);
}
-EXPORT_SYMBOL(t3_register_cpl_handler);
/*
- * T3CDEV's receive method.
+ * TOEDEV's receive method.
*/
-int process_rx(struct t3cdev *dev, struct sk_buff **skbs, int n)
+int
+process_rx(struct toedev *dev, struct mbuf **m, int n)
{
while (n--) {
- struct sk_buff *skb = *skbs++;
+ struct mbuf *m0 = *m++;
unsigned int opcode = G_OPCODE(ntohl(skb->csum));
- int ret = cpl_handlers[opcode] (dev, skb);
+ int ret = cpl_handlers[opcode] (dev, m0);
#if VALIDATE_TID
if (ret & CPL_RET_UNKNOWN_TID) {
- union opcode_tid *p = cplhdr(skb);
+ union opcode_tid *p = cplhdr(m0);
- printk(KERN_ERR "%s: CPL message (opcode %u) had "
+ log(LOG_ERR, "%s: CPL message (opcode %u) had "
"unknown TID %u\n", dev->name, opcode,
G_TID(ntohl(p->opcode_tid)));
}
#endif
if (ret & CPL_RET_BUF_DONE)
- kfree_skb(skb);
+ m_freem(m0);
>>> TRUNCATED FOR MAIL (1000 lines) <<<
More information about the p4-projects
mailing list