Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * This file is part of the Chelsio T4/T5/T6 Ethernet driver for Linux.
0003  *
0004  * Copyright (c) 2017 Chelsio Communications, Inc. All rights reserved.
0005  *
0006  * This software is available to you under a choice of one of two
0007  * licenses.  You may choose to be licensed under the terms of the GNU
0008  * General Public License (GPL) Version 2, available from the file
0009  * COPYING in the main directory of this source tree, or the
0010  * OpenIB.org BSD license below:
0011  *
0012  *     Redistribution and use in source and binary forms, with or
0013  *     without modification, are permitted provided that the following
0014  *     conditions are met:
0015  *
0016  *      - Redistributions of source code must retain the above
0017  *        copyright notice, this list of conditions and the following
0018  *        disclaimer.
0019  *
0020  *      - Redistributions in binary form must reproduce the above
0021  *        copyright notice, this list of conditions and the following
0022  *        disclaimer in the documentation and/or other materials
0023  *        provided with the distribution.
0024  *
0025  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
0026  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
0027  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
0028  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
0029  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
0030  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
0031  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
0032  * SOFTWARE.
0033  */
0034 
0035 #ifndef __CXGB4_SMT_H
0036 #define __CXGB4_SMT_H
0037 
0038 #include <linux/spinlock.h>
0039 #include <linux/if_ether.h>
0040 #include <linux/atomic.h>
0041 
0042 struct adapter;
0043 struct cpl_smt_write_rpl;
0044 
0045 /* SMT related handling. Heavily adapted based on l2t ops in l2t.h/l2t.c
0046  */
0047 enum {
0048     SMT_STATE_SWITCHING,
0049     SMT_STATE_UNUSED,
0050     SMT_STATE_ERROR
0051 };
0052 
0053 enum {
0054     SMT_SIZE = 256
0055 };
0056 
0057 struct smt_entry {
0058     u16 state;
0059     u16 idx;
0060     u16 pfvf;
0061     u8 src_mac[ETH_ALEN];
0062     int refcnt;
0063     spinlock_t lock;    /* protect smt entry add,removal */
0064 };
0065 
0066 struct smt_data {
0067     unsigned int smt_size;
0068     rwlock_t lock;
0069     struct smt_entry smtab[];
0070 };
0071 
0072 struct smt_data *t4_init_smt(void);
0073 struct smt_entry *cxgb4_smt_alloc_switching(struct net_device *dev, u8 *smac);
0074 void cxgb4_smt_release(struct smt_entry *e);
0075 void do_smt_write_rpl(struct adapter *p, const struct cpl_smt_write_rpl *rpl);
0076 #endif /* __CXGB4_SMT_H */