33 #include <linux/list.h>
34 #include <linux/slab.h>
39 #include <linux/if_vlan.h>
43 #include <linux/export.h>
61 static const unsigned int MAX_ATIDS = 64 * 1024;
62 static const unsigned int ATID_BASE = 0x10000;
64 static void cxgb_neigh_update(
struct neighbour *neigh);
69 static inline int offload_activated(
struct t3cdev *
tdev)
92 if (offload_activated(tdev))
117 if (offload_activated(tdev))
176 const unsigned char *
mac,
189 }
else if (netif_is_bond_slave(dev)) {
199 static int cxgb_ulp_iscsi_ctl(
struct adapter *adapter,
unsigned int req,
204 unsigned int val = 0;
215 for (i = 0; i < 4; i++, val >>= 8)
236 "%s, iscsi set MaxRxData to 16224 (0x%x).\n",
253 for (i = 0; i < 4; i++)
257 "%s, setting iscsi pgsz 0x%x, %u,%u,%u,%u.\n",
271 #define ASYNC_NOTIF_RSPQ 0
273 static int cxgb_rdma_ctl(
struct adapter *adapter,
unsigned int req,
void *data)
304 spin_unlock_irqrestore(&adapter->
sge.reg_lock, flags);
311 if ((t->
addr & 7) || (t->
len & 7))
316 mem = &adapter->
pmrx;
318 mem = &adapter->
pmtx;
332 spin_lock_irq(&adapter->
sge.reg_lock);
339 spin_unlock_irq(&adapter->
sge.reg_lock);
343 spin_lock_irq(&adapter->
sge.reg_lock);
345 spin_unlock_irq(&adapter->
sge.reg_lock);
350 spin_lock_irq(&adapter->
sge.reg_lock);
356 spin_unlock_irq(&adapter->
sge.reg_lock);
371 static int cxgb_offload_ctl(
struct t3cdev *tdev,
unsigned int req,
void *data)
373 struct adapter *adapter =
tdev2adap(tdev);
391 *(
unsigned int *)data = 1 << 20;
395 tid->
num = t3_mc5_size(&adapter->
mc5) -
396 adapter->
params.mc5.nroutes -
397 adapter->
params.mc5.nfilters - adapter->
params.mc5.nservers;
403 tid->
base = t3_mc5_size(&adapter->
mc5) - tid->
num -
404 adapter->
params.mc5.nfilters - adapter->
params.mc5.nroutes;
407 *(
unsigned int *)data = 2048;
416 iffmacp->
dev = get_iff_from_mac(adapter, iffmacp->
mac_addr,
430 ports->lldevs[i] = adapter->
port[i];
434 if (!offload_running(adapter))
436 return cxgb_ulp_iscsi_ctl(adapter, req, data);
444 if (!offload_running(adapter))
446 return cxgb_rdma_ctl(adapter, req, data);
478 static int rx_offload_blackhole(
struct t3cdev *dev,
struct sk_buff **skbs,
486 static void dummy_neigh_update(
struct t3cdev *dev,
struct neighbour *neigh)
492 dev->
recv = rx_offload_blackhole;
505 spin_lock_bh(&t->atid_lock);
509 spin_unlock_bh(&t->atid_lock);
534 void *
ctx,
unsigned int tid)
548 static inline void mk_tid_release(
struct sk_buff *
skb,
unsigned int tid)
583 mk_tid_release(skb, p - td->
tid_maps.tid_tab);
637 mk_tid_release(skb, tid);
654 spin_lock_bh(&t->atid_lock);
666 spin_unlock_bh(&t->atid_lock);
697 const struct port_info *pi = netdev_priv(dev);
704 static int do_smt_write_rpl(
struct t3cdev *dev,
struct sk_buff *skb)
710 "Unexpected SMT_WRITE_RPL status %u for entry %u\n",
716 static int do_l2t_write_rpl(
struct t3cdev *dev,
struct sk_buff *skb)
722 "Unexpected L2T_WRITE_RPL status %u for entry %u\n",
728 static int do_rte_write_rpl(
struct t3cdev *dev,
struct sk_buff *skb)
734 "Unexpected RTE_WRITE_RPL status %u for entry %u\n",
740 static int do_act_open_rpl(
struct t3cdev *dev,
struct sk_buff *skb)
746 t3c_tid = lookup_atid(&(
T3C_DATA(dev))->tid_maps, atid);
747 if (t3c_tid && t3c_tid->
ctx && t3c_tid->
client &&
748 t3c_tid->
client->handlers &&
760 static int do_stid_rpl(
struct t3cdev *dev,
struct sk_buff *skb)
766 t3c_tid = lookup_stid(&(
T3C_DATA(dev))->tid_maps, stid);
767 if (t3c_tid && t3c_tid->
ctx && t3c_tid->
client->handlers &&
778 static int do_hwtid_rpl(
struct t3cdev *dev,
struct sk_buff *skb)
784 t3c_tid = lookup_tid(&(
T3C_DATA(dev))->tid_maps, hwtid);
785 if (t3c_tid && t3c_tid->
ctx && t3c_tid->
client->handlers &&
802 unsigned int tid =
GET_TID(req);
805 printk(
"%s: passive open TID %u too large\n",
811 t3c_tid = lookup_stid(t, stid);
812 if (t3c_tid && t3c_tid->
ctx && t3c_tid->
client->handlers &&
833 if (
likely(!skb_cloned(skb))) {
835 __skb_trim(skb, len);
838 skb = alloc_skb(len, gfp);
845 static int do_abort_req_rss(
struct t3cdev *dev,
struct sk_buff *skb)
851 t3c_tid = lookup_tid(&(
T3C_DATA(dev))->tid_maps, hwtid);
852 if (t3c_tid && t3c_tid->
ctx && t3c_tid->
client->handlers &&
860 unsigned int tid =
GET_TID(req);
867 reply_skb = cxgb3_get_cpl_reply_skb(skb,
873 printk(
"do_abort_req_rss: couldn't get skb!\n");
878 rpl = cplhdr(reply_skb);
890 static int do_act_establish(
struct t3cdev *dev,
struct sk_buff *skb)
896 unsigned int tid =
GET_TID(req);
899 printk(
"%s: active establish TID %u too large\n",
905 t3c_tid = lookup_atid(t, atid);
906 if (t3c_tid && t3c_tid->
ctx && t3c_tid->
client->handlers &&
924 skb_reset_mac_header(skb);
935 static inline u32 get_hwtid(
struct sk_buff *skb)
940 static inline u32 get_opcode(
struct sk_buff *skb)
947 unsigned int hwtid = get_hwtid(skb);
948 unsigned int opcode = get_opcode(skb);
951 t3c_tid = lookup_tid(&(
T3C_DATA(dev))->tid_maps, hwtid);
952 if (t3c_tid && t3c_tid->
ctx && t3c_tid->
client->handlers &&
953 t3c_tid->
client->handlers[opcode]) {
968 cxgb_neigh_update((
struct neighbour *)ctx);
986 .notifier_call = nb_callback
992 static int do_bad_cpl(
struct t3cdev *dev,
struct sk_buff *skb)
1011 cpl_handlers[
opcode] = h ? h : do_bad_cpl;
1014 "opcode %x failed\n", opcode);
1022 static int process_rx(
struct t3cdev *dev,
struct sk_buff **skbs,
int n)
1025 struct sk_buff *skb = *skbs++;
1026 unsigned int opcode = get_opcode(skb);
1034 "unknown TID %u\n", dev->name, opcode,
1052 r = dev->
send(dev, skb);
1059 static int is_offloading(
struct net_device *dev)
1067 if (dev == adapter->
port[i]) {
1077 static void cxgb_neigh_update(
struct neighbour *neigh)
1084 if (dev && (is_offloading(dev))) {
1111 tdev->
send(tdev, skb);
1126 olddev = old_neigh->
dev;
1127 newdev = new_neigh->
dev;
1129 if (!is_offloading(olddev))
1131 if (!is_offloading(newdev)) {
1133 "device ignored.\n", __func__);
1140 "offload device ignored.\n", __func__);
1154 for (tid = 0; tid < ti->
ntids; tid++) {
1155 te = lookup_tid(ti, tid);
1158 update_tcb = te->
client->redirect(te->
ctx, old,
new, e);
1161 l2t_hold(
L2DATA(tdev), e);
1163 set_l2t_ix(tdev, tid, e);
1167 l2t_release(tdev, e);
1188 if (is_vmalloc_addr(addr))
1197 static int init_tid_tabs(
struct tid_info *t,
unsigned int ntids,
1198 unsigned int natids,
unsigned int nstids,
1199 unsigned int atid_base,
unsigned int stid_base)
1201 unsigned long size = ntids *
sizeof(*t->
tid_tab) +
1238 static void free_tid_maps(
struct tid_info *t)
1243 static inline void add_adapter(
struct adapter *adap)
1250 static inline void remove_adapter(
struct adapter *adap)
1264 unsigned int l2t_capacity;
1285 err = init_tid_tabs(&t->
tid_maps, tid_range.
num, natids,
1286 stid_range.
num, ATID_BASE, stid_range.
base);
1299 dev->
recv = process_rx;
1303 if (list_empty(&adapter_list))
1309 add_adapter(adapter);
1333 remove_adapter(adapter);
1334 if (list_empty(&adapter_list))
1349 static inline void register_tdev(
struct t3cdev *tdev)
1359 static inline void unregister_tdev(
struct t3cdev *tdev)
1366 static inline int adap2type(
struct adapter *adapter)
1370 switch (adapter->
params.rev) {
1393 tdev->
ctl = cxgb_offload_ctl;
1394 tdev->
type = adap2type(adapter);
1396 register_tdev(tdev);
1406 unregister_tdev(tdev);
1414 cpl_handlers[i] = do_bad_cpl;