1 /*- 2 * Copyright (c) 2011 Chelsio Communications, Inc. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * $FreeBSD$ 27 * 28 */ 29 30 #ifndef __T4_L2T_H 31 #define __T4_L2T_H 32 33 enum { L2T_SIZE = 4096 }; /* # of L2T entries */ 34 35 /* 36 * Each L2T entry plays multiple roles. First of all, it keeps state for the 37 * corresponding entry of the HW L2 table and maintains a queue of offload 38 * packets awaiting address resolution. Second, it is a node of a hash table 39 * chain, where the nodes of the chain are linked together through their next 40 * pointer. Finally, each node is a bucket of a hash table, pointing to the 41 * first element in its chain through its first pointer. 42 */ 43 struct l2t_entry { 44 uint16_t state; /* entry state */ 45 uint16_t idx; /* entry index */ 46 uint32_t addr[4]; /* next hop IP or IPv6 address */ 47 struct ifnet *ifp; /* outgoing interface */ 48 uint16_t smt_idx; /* SMT index */ 49 uint16_t vlan; /* VLAN TCI (id: 0-11, prio: 13-15) */ 50 int ifindex; /* interface index */ 51 struct llentry *lle; /* llentry for next hop */ 52 struct l2t_entry *first; /* start of hash chain */ 53 struct l2t_entry *next; /* next l2t_entry on chain */ 54 struct mbuf *arpq_head; /* list of mbufs awaiting resolution */ 55 struct mbuf *arpq_tail; 56 struct mtx lock; 57 volatile uint32_t refcnt; /* entry reference count */ 58 uint16_t hash; /* hash bucket the entry is on */ 59 uint8_t v6; /* whether entry is for IPv6 */ 60 uint8_t lport; /* associated offload logical port */ 61 uint8_t dmac[ETHER_ADDR_LEN]; /* next hop's MAC address */ 62 }; 63 64 struct l2t_data *t4_init_l2t(int); 65 int t4_free_l2t(struct l2t_data *); 66 struct l2t_entry *t4_l2t_alloc_switching(struct l2t_data *); 67 int t4_l2t_set_switching(struct adapter *, struct l2t_entry *, uint16_t, 68 uint8_t, uint8_t *); 69 void t4_l2t_release(struct l2t_entry *); 70 71 #endif /* __T4_L2T_H */ 72