l2t.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. /*
  2. * This file is part of the Chelsio T4 Ethernet driver for Linux.
  3. *
  4. * Copyright (c) 2003-2010 Chelsio Communications, Inc. All rights reserved.
  5. *
  6. * This software is available to you under a choice of one of two
  7. * licenses. You may choose to be licensed under the terms of the GNU
  8. * General Public License (GPL) Version 2, available from the file
  9. * COPYING in the main directory of this source tree, or the
  10. * OpenIB.org BSD license below:
  11. *
  12. * Redistribution and use in source and binary forms, with or
  13. * without modification, are permitted provided that the following
  14. * conditions are met:
  15. *
  16. * - Redistributions of source code must retain the above
  17. * copyright notice, this list of conditions and the following
  18. * disclaimer.
  19. *
  20. * - Redistributions in binary form must reproduce the above
  21. * copyright notice, this list of conditions and the following
  22. * disclaimer in the documentation and/or other materials
  23. * provided with the distribution.
  24. *
  25. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  26. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  27. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  28. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  29. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  30. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  31. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  32. * SOFTWARE.
  33. */
  34. #include <linux/skbuff.h>
  35. #include <linux/netdevice.h>
  36. #include <linux/if.h>
  37. #include <linux/if_vlan.h>
  38. #include <linux/jhash.h>
  39. #include <net/neighbour.h>
  40. #include "cxgb4.h"
  41. #include "l2t.h"
  42. #include "t4_msg.h"
  43. #include "t4fw_api.h"
  44. #define VLAN_NONE 0xfff
  45. /* identifies sync vs async L2T_WRITE_REQs */
  46. #define F_SYNC_WR (1 << 12)
  47. enum {
  48. L2T_STATE_VALID, /* entry is up to date */
  49. L2T_STATE_STALE, /* entry may be used but needs revalidation */
  50. L2T_STATE_RESOLVING, /* entry needs address resolution */
  51. L2T_STATE_SYNC_WRITE, /* synchronous write of entry underway */
  52. /* when state is one of the below the entry is not hashed */
  53. L2T_STATE_SWITCHING, /* entry is being used by a switching filter */
  54. L2T_STATE_UNUSED /* entry not in use */
  55. };
  56. struct l2t_data {
  57. rwlock_t lock;
  58. atomic_t nfree; /* number of free entries */
  59. struct l2t_entry *rover; /* starting point for next allocation */
  60. struct l2t_entry l2tab[L2T_SIZE];
  61. };
  62. static inline unsigned int vlan_prio(const struct l2t_entry *e)
  63. {
  64. return e->vlan >> 13;
  65. }
  66. static inline void l2t_hold(struct l2t_data *d, struct l2t_entry *e)
  67. {
  68. if (atomic_add_return(1, &e->refcnt) == 1) /* 0 -> 1 transition */
  69. atomic_dec(&d->nfree);
  70. }
  71. /*
  72. * To avoid having to check address families we do not allow v4 and v6
  73. * neighbors to be on the same hash chain. We keep v4 entries in the first
  74. * half of available hash buckets and v6 in the second.
  75. */
  76. enum {
  77. L2T_SZ_HALF = L2T_SIZE / 2,
  78. L2T_HASH_MASK = L2T_SZ_HALF - 1
  79. };
  80. static inline unsigned int arp_hash(const u32 *key, int ifindex)
  81. {
  82. return jhash_2words(*key, ifindex, 0) & L2T_HASH_MASK;
  83. }
  84. static inline unsigned int ipv6_hash(const u32 *key, int ifindex)
  85. {
  86. u32 xor = key[0] ^ key[1] ^ key[2] ^ key[3];
  87. return L2T_SZ_HALF + (jhash_2words(xor, ifindex, 0) & L2T_HASH_MASK);
  88. }
  89. static unsigned int addr_hash(const u32 *addr, int addr_len, int ifindex)
  90. {
  91. return addr_len == 4 ? arp_hash(addr, ifindex) :
  92. ipv6_hash(addr, ifindex);
  93. }
  94. /*
  95. * Checks if an L2T entry is for the given IP/IPv6 address. It does not check
  96. * whether the L2T entry and the address are of the same address family.
  97. * Callers ensure an address is only checked against L2T entries of the same
  98. * family, something made trivial by the separation of IP and IPv6 hash chains
  99. * mentioned above. Returns 0 if there's a match,
  100. */
  101. static int addreq(const struct l2t_entry *e, const u32 *addr)
  102. {
  103. if (e->v6)
  104. return (e->addr[0] ^ addr[0]) | (e->addr[1] ^ addr[1]) |
  105. (e->addr[2] ^ addr[2]) | (e->addr[3] ^ addr[3]);
  106. return e->addr[0] ^ addr[0];
  107. }
  108. static void neigh_replace(struct l2t_entry *e, struct neighbour *n)
  109. {
  110. neigh_hold(n);
  111. if (e->neigh)
  112. neigh_release(e->neigh);
  113. e->neigh = n;
  114. }
  115. /*
  116. * Write an L2T entry. Must be called with the entry locked.
  117. * The write may be synchronous or asynchronous.
  118. */
  119. static int write_l2e(struct adapter *adap, struct l2t_entry *e, int sync)
  120. {
  121. struct sk_buff *skb;
  122. struct cpl_l2t_write_req *req;
  123. skb = alloc_skb(sizeof(*req), GFP_ATOMIC);
  124. if (!skb)
  125. return -ENOMEM;
  126. req = (struct cpl_l2t_write_req *)__skb_put(skb, sizeof(*req));
  127. INIT_TP_WR(req, 0);
  128. OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_L2T_WRITE_REQ,
  129. e->idx | (sync ? F_SYNC_WR : 0) |
  130. TID_QID(adap->sge.fw_evtq.abs_id)));
  131. req->params = htons(L2T_W_PORT(e->lport) | L2T_W_NOREPLY(!sync));
  132. req->l2t_idx = htons(e->idx);
  133. req->vlan = htons(e->vlan);
  134. if (e->neigh)
  135. memcpy(e->dmac, e->neigh->ha, sizeof(e->dmac));
  136. memcpy(req->dst_mac, e->dmac, sizeof(req->dst_mac));
  137. set_wr_txq(skb, CPL_PRIORITY_CONTROL, 0);
  138. t4_ofld_send(adap, skb);
  139. if (sync && e->state != L2T_STATE_SWITCHING)
  140. e->state = L2T_STATE_SYNC_WRITE;
  141. return 0;
  142. }
  143. /*
  144. * Send packets waiting in an L2T entry's ARP queue. Must be called with the
  145. * entry locked.
  146. */
  147. static void send_pending(struct adapter *adap, struct l2t_entry *e)
  148. {
  149. while (e->arpq_head) {
  150. struct sk_buff *skb = e->arpq_head;
  151. e->arpq_head = skb->next;
  152. skb->next = NULL;
  153. t4_ofld_send(adap, skb);
  154. }
  155. e->arpq_tail = NULL;
  156. }
  157. /*
  158. * Process a CPL_L2T_WRITE_RPL. Wake up the ARP queue if it completes a
  159. * synchronous L2T_WRITE. Note that the TID in the reply is really the L2T
  160. * index it refers to.
  161. */
  162. void do_l2t_write_rpl(struct adapter *adap, const struct cpl_l2t_write_rpl *rpl)
  163. {
  164. unsigned int tid = GET_TID(rpl);
  165. unsigned int idx = tid & (L2T_SIZE - 1);
  166. if (unlikely(rpl->status != CPL_ERR_NONE)) {
  167. dev_err(adap->pdev_dev,
  168. "Unexpected L2T_WRITE_RPL status %u for entry %u\n",
  169. rpl->status, idx);
  170. return;
  171. }
  172. if (tid & F_SYNC_WR) {
  173. struct l2t_entry *e = &adap->l2t->l2tab[idx];
  174. spin_lock(&e->lock);
  175. if (e->state != L2T_STATE_SWITCHING) {
  176. send_pending(adap, e);
  177. e->state = (e->neigh->nud_state & NUD_STALE) ?
  178. L2T_STATE_STALE : L2T_STATE_VALID;
  179. }
  180. spin_unlock(&e->lock);
  181. }
  182. }
  183. /*
  184. * Add a packet to an L2T entry's queue of packets awaiting resolution.
  185. * Must be called with the entry's lock held.
  186. */
  187. static inline void arpq_enqueue(struct l2t_entry *e, struct sk_buff *skb)
  188. {
  189. skb->next = NULL;
  190. if (e->arpq_head)
  191. e->arpq_tail->next = skb;
  192. else
  193. e->arpq_head = skb;
  194. e->arpq_tail = skb;
  195. }
  196. int cxgb4_l2t_send(struct net_device *dev, struct sk_buff *skb,
  197. struct l2t_entry *e)
  198. {
  199. struct adapter *adap = netdev2adap(dev);
  200. again:
  201. switch (e->state) {
  202. case L2T_STATE_STALE: /* entry is stale, kick off revalidation */
  203. neigh_event_send(e->neigh, NULL);
  204. spin_lock_bh(&e->lock);
  205. if (e->state == L2T_STATE_STALE)
  206. e->state = L2T_STATE_VALID;
  207. spin_unlock_bh(&e->lock);
  208. case L2T_STATE_VALID: /* fast-path, send the packet on */
  209. return t4_ofld_send(adap, skb);
  210. case L2T_STATE_RESOLVING:
  211. case L2T_STATE_SYNC_WRITE:
  212. spin_lock_bh(&e->lock);
  213. if (e->state != L2T_STATE_SYNC_WRITE &&
  214. e->state != L2T_STATE_RESOLVING) {
  215. spin_unlock_bh(&e->lock);
  216. goto again;
  217. }
  218. arpq_enqueue(e, skb);
  219. spin_unlock_bh(&e->lock);
  220. if (e->state == L2T_STATE_RESOLVING &&
  221. !neigh_event_send(e->neigh, NULL)) {
  222. spin_lock_bh(&e->lock);
  223. if (e->state == L2T_STATE_RESOLVING && e->arpq_head)
  224. write_l2e(adap, e, 1);
  225. spin_unlock_bh(&e->lock);
  226. }
  227. }
  228. return 0;
  229. }
  230. EXPORT_SYMBOL(cxgb4_l2t_send);
  231. /*
  232. * Allocate a free L2T entry. Must be called with l2t_data.lock held.
  233. */
  234. static struct l2t_entry *alloc_l2e(struct l2t_data *d)
  235. {
  236. struct l2t_entry *end, *e, **p;
  237. if (!atomic_read(&d->nfree))
  238. return NULL;
  239. /* there's definitely a free entry */
  240. for (e = d->rover, end = &d->l2tab[L2T_SIZE]; e != end; ++e)
  241. if (atomic_read(&e->refcnt) == 0)
  242. goto found;
  243. for (e = d->l2tab; atomic_read(&e->refcnt); ++e)
  244. ;
  245. found:
  246. d->rover = e + 1;
  247. atomic_dec(&d->nfree);
  248. /*
  249. * The entry we found may be an inactive entry that is
  250. * presently in the hash table. We need to remove it.
  251. */
  252. if (e->state < L2T_STATE_SWITCHING)
  253. for (p = &d->l2tab[e->hash].first; *p; p = &(*p)->next)
  254. if (*p == e) {
  255. *p = e->next;
  256. e->next = NULL;
  257. break;
  258. }
  259. e->state = L2T_STATE_UNUSED;
  260. return e;
  261. }
  262. /*
  263. * Called when an L2T entry has no more users.
  264. */
  265. static void t4_l2e_free(struct l2t_entry *e)
  266. {
  267. struct l2t_data *d;
  268. spin_lock_bh(&e->lock);
  269. if (atomic_read(&e->refcnt) == 0) { /* hasn't been recycled */
  270. if (e->neigh) {
  271. neigh_release(e->neigh);
  272. e->neigh = NULL;
  273. }
  274. }
  275. spin_unlock_bh(&e->lock);
  276. d = container_of(e, struct l2t_data, l2tab[e->idx]);
  277. atomic_inc(&d->nfree);
  278. }
  279. void cxgb4_l2t_release(struct l2t_entry *e)
  280. {
  281. if (atomic_dec_and_test(&e->refcnt))
  282. t4_l2e_free(e);
  283. }
  284. EXPORT_SYMBOL(cxgb4_l2t_release);
  285. /*
  286. * Update an L2T entry that was previously used for the same next hop as neigh.
  287. * Must be called with softirqs disabled.
  288. */
  289. static void reuse_entry(struct l2t_entry *e, struct neighbour *neigh)
  290. {
  291. unsigned int nud_state;
  292. spin_lock(&e->lock); /* avoid race with t4_l2t_free */
  293. if (neigh != e->neigh)
  294. neigh_replace(e, neigh);
  295. nud_state = neigh->nud_state;
  296. if (memcmp(e->dmac, neigh->ha, sizeof(e->dmac)) ||
  297. !(nud_state & NUD_VALID))
  298. e->state = L2T_STATE_RESOLVING;
  299. else if (nud_state & NUD_CONNECTED)
  300. e->state = L2T_STATE_VALID;
  301. else
  302. e->state = L2T_STATE_STALE;
  303. spin_unlock(&e->lock);
  304. }
  305. struct l2t_entry *cxgb4_l2t_get(struct l2t_data *d, struct neighbour *neigh,
  306. const struct net_device *physdev,
  307. unsigned int priority)
  308. {
  309. u8 lport;
  310. u16 vlan;
  311. struct l2t_entry *e;
  312. int addr_len = neigh->tbl->key_len;
  313. u32 *addr = (u32 *)neigh->primary_key;
  314. int ifidx = neigh->dev->ifindex;
  315. int hash = addr_hash(addr, addr_len, ifidx);
  316. if (neigh->dev->flags & IFF_LOOPBACK)
  317. lport = netdev2pinfo(physdev)->tx_chan + 4;
  318. else
  319. lport = netdev2pinfo(physdev)->lport;
  320. if (neigh->dev->priv_flags & IFF_802_1Q_VLAN)
  321. vlan = vlan_dev_vlan_id(neigh->dev);
  322. else
  323. vlan = VLAN_NONE;
  324. write_lock_bh(&d->lock);
  325. for (e = d->l2tab[hash].first; e; e = e->next)
  326. if (!addreq(e, addr) && e->ifindex == ifidx &&
  327. e->vlan == vlan && e->lport == lport) {
  328. l2t_hold(d, e);
  329. if (atomic_read(&e->refcnt) == 1)
  330. reuse_entry(e, neigh);
  331. goto done;
  332. }
  333. /* Need to allocate a new entry */
  334. e = alloc_l2e(d);
  335. if (e) {
  336. spin_lock(&e->lock); /* avoid race with t4_l2t_free */
  337. e->state = L2T_STATE_RESOLVING;
  338. memcpy(e->addr, addr, addr_len);
  339. e->ifindex = ifidx;
  340. e->hash = hash;
  341. e->lport = lport;
  342. e->v6 = addr_len == 16;
  343. atomic_set(&e->refcnt, 1);
  344. neigh_replace(e, neigh);
  345. e->vlan = vlan;
  346. e->next = d->l2tab[hash].first;
  347. d->l2tab[hash].first = e;
  348. spin_unlock(&e->lock);
  349. }
  350. done:
  351. write_unlock_bh(&d->lock);
  352. return e;
  353. }
  354. EXPORT_SYMBOL(cxgb4_l2t_get);
  355. /*
  356. * Called when address resolution fails for an L2T entry to handle packets
  357. * on the arpq head. If a packet specifies a failure handler it is invoked,
  358. * otherwise the packet is sent to the device.
  359. */
  360. static void handle_failed_resolution(struct adapter *adap, struct sk_buff *arpq)
  361. {
  362. while (arpq) {
  363. struct sk_buff *skb = arpq;
  364. const struct l2t_skb_cb *cb = L2T_SKB_CB(skb);
  365. arpq = skb->next;
  366. skb->next = NULL;
  367. if (cb->arp_err_handler)
  368. cb->arp_err_handler(cb->handle, skb);
  369. else
  370. t4_ofld_send(adap, skb);
  371. }
  372. }
  373. /*
  374. * Called when the host's neighbor layer makes a change to some entry that is
  375. * loaded into the HW L2 table.
  376. */
  377. void t4_l2t_update(struct adapter *adap, struct neighbour *neigh)
  378. {
  379. struct l2t_entry *e;
  380. struct sk_buff *arpq = NULL;
  381. struct l2t_data *d = adap->l2t;
  382. int addr_len = neigh->tbl->key_len;
  383. u32 *addr = (u32 *) neigh->primary_key;
  384. int ifidx = neigh->dev->ifindex;
  385. int hash = addr_hash(addr, addr_len, ifidx);
  386. read_lock_bh(&d->lock);
  387. for (e = d->l2tab[hash].first; e; e = e->next)
  388. if (!addreq(e, addr) && e->ifindex == ifidx) {
  389. spin_lock(&e->lock);
  390. if (atomic_read(&e->refcnt))
  391. goto found;
  392. spin_unlock(&e->lock);
  393. break;
  394. }
  395. read_unlock_bh(&d->lock);
  396. return;
  397. found:
  398. read_unlock(&d->lock);
  399. if (neigh != e->neigh)
  400. neigh_replace(e, neigh);
  401. if (e->state == L2T_STATE_RESOLVING) {
  402. if (neigh->nud_state & NUD_FAILED) {
  403. arpq = e->arpq_head;
  404. e->arpq_head = e->arpq_tail = NULL;
  405. } else if ((neigh->nud_state & (NUD_CONNECTED | NUD_STALE)) &&
  406. e->arpq_head) {
  407. write_l2e(adap, e, 1);
  408. }
  409. } else {
  410. e->state = neigh->nud_state & NUD_CONNECTED ?
  411. L2T_STATE_VALID : L2T_STATE_STALE;
  412. if (memcmp(e->dmac, neigh->ha, sizeof(e->dmac)))
  413. write_l2e(adap, e, 0);
  414. }
  415. spin_unlock_bh(&e->lock);
  416. if (arpq)
  417. handle_failed_resolution(adap, arpq);
  418. }
  419. /*
  420. * Allocate an L2T entry for use by a switching rule. Such entries need to be
  421. * explicitly freed and while busy they are not on any hash chain, so normal
  422. * address resolution updates do not see them.
  423. */
  424. struct l2t_entry *t4_l2t_alloc_switching(struct l2t_data *d)
  425. {
  426. struct l2t_entry *e;
  427. write_lock_bh(&d->lock);
  428. e = alloc_l2e(d);
  429. if (e) {
  430. spin_lock(&e->lock); /* avoid race with t4_l2t_free */
  431. e->state = L2T_STATE_SWITCHING;
  432. atomic_set(&e->refcnt, 1);
  433. spin_unlock(&e->lock);
  434. }
  435. write_unlock_bh(&d->lock);
  436. return e;
  437. }
  438. /*
  439. * Sets/updates the contents of a switching L2T entry that has been allocated
  440. * with an earlier call to @t4_l2t_alloc_switching.
  441. */
  442. int t4_l2t_set_switching(struct adapter *adap, struct l2t_entry *e, u16 vlan,
  443. u8 port, u8 *eth_addr)
  444. {
  445. e->vlan = vlan;
  446. e->lport = port;
  447. memcpy(e->dmac, eth_addr, ETH_ALEN);
  448. return write_l2e(adap, e, 0);
  449. }
  450. struct l2t_data *t4_init_l2t(void)
  451. {
  452. int i;
  453. struct l2t_data *d;
  454. d = t4_alloc_mem(sizeof(*d));
  455. if (!d)
  456. return NULL;
  457. d->rover = d->l2tab;
  458. atomic_set(&d->nfree, L2T_SIZE);
  459. rwlock_init(&d->lock);
  460. for (i = 0; i < L2T_SIZE; ++i) {
  461. d->l2tab[i].idx = i;
  462. d->l2tab[i].state = L2T_STATE_UNUSED;
  463. spin_lock_init(&d->l2tab[i].lock);
  464. atomic_set(&d->l2tab[i].refcnt, 0);
  465. }
  466. return d;
  467. }
  468. #include <linux/module.h>
  469. #include <linux/debugfs.h>
  470. #include <linux/seq_file.h>
  471. static inline void *l2t_get_idx(struct seq_file *seq, loff_t pos)
  472. {
  473. struct l2t_entry *l2tab = seq->private;
  474. return pos >= L2T_SIZE ? NULL : &l2tab[pos];
  475. }
  476. static void *l2t_seq_start(struct seq_file *seq, loff_t *pos)
  477. {
  478. return *pos ? l2t_get_idx(seq, *pos - 1) : SEQ_START_TOKEN;
  479. }
  480. static void *l2t_seq_next(struct seq_file *seq, void *v, loff_t *pos)
  481. {
  482. v = l2t_get_idx(seq, *pos);
  483. if (v)
  484. ++*pos;
  485. return v;
  486. }
  487. static void l2t_seq_stop(struct seq_file *seq, void *v)
  488. {
  489. }
  490. static char l2e_state(const struct l2t_entry *e)
  491. {
  492. switch (e->state) {
  493. case L2T_STATE_VALID: return 'V';
  494. case L2T_STATE_STALE: return 'S';
  495. case L2T_STATE_SYNC_WRITE: return 'W';
  496. case L2T_STATE_RESOLVING: return e->arpq_head ? 'A' : 'R';
  497. case L2T_STATE_SWITCHING: return 'X';
  498. default:
  499. return 'U';
  500. }
  501. }
  502. static int l2t_seq_show(struct seq_file *seq, void *v)
  503. {
  504. if (v == SEQ_START_TOKEN)
  505. seq_puts(seq, " Idx IP address "
  506. "Ethernet address VLAN/P LP State Users Port\n");
  507. else {
  508. char ip[60];
  509. struct l2t_entry *e = v;
  510. spin_lock_bh(&e->lock);
  511. if (e->state == L2T_STATE_SWITCHING)
  512. ip[0] = '\0';
  513. else
  514. sprintf(ip, e->v6 ? "%pI6c" : "%pI4", e->addr);
  515. seq_printf(seq, "%4u %-25s %17pM %4d %u %2u %c %5u %s\n",
  516. e->idx, ip, e->dmac,
  517. e->vlan & VLAN_VID_MASK, vlan_prio(e), e->lport,
  518. l2e_state(e), atomic_read(&e->refcnt),
  519. e->neigh ? e->neigh->dev->name : "");
  520. spin_unlock_bh(&e->lock);
  521. }
  522. return 0;
  523. }
  524. static const struct seq_operations l2t_seq_ops = {
  525. .start = l2t_seq_start,
  526. .next = l2t_seq_next,
  527. .stop = l2t_seq_stop,
  528. .show = l2t_seq_show
  529. };
  530. static int l2t_seq_open(struct inode *inode, struct file *file)
  531. {
  532. int rc = seq_open(file, &l2t_seq_ops);
  533. if (!rc) {
  534. struct adapter *adap = inode->i_private;
  535. struct seq_file *seq = file->private_data;
  536. seq->private = adap->l2t->l2tab;
  537. }
  538. return rc;
  539. }
  540. const struct file_operations t4_l2t_fops = {
  541. .owner = THIS_MODULE,
  542. .open = l2t_seq_open,
  543. .read = seq_read,
  544. .llseek = seq_lseek,
  545. .release = seq_release,
  546. };