13bdb376eSKumar Sanghvi /* 23bdb376eSKumar Sanghvi * This file is part of the Chelsio T4/T5/T6 Ethernet driver for Linux. 33bdb376eSKumar Sanghvi * 43bdb376eSKumar Sanghvi * Copyright (c) 2017 Chelsio Communications, Inc. All rights reserved. 53bdb376eSKumar Sanghvi * 63bdb376eSKumar Sanghvi * This software is available to you under a choice of one of two 73bdb376eSKumar Sanghvi * licenses. You may choose to be licensed under the terms of the GNU 83bdb376eSKumar Sanghvi * General Public License (GPL) Version 2, available from the file 93bdb376eSKumar Sanghvi * COPYING in the main directory of this source tree, or the 103bdb376eSKumar Sanghvi * OpenIB.org BSD license below: 113bdb376eSKumar Sanghvi * 123bdb376eSKumar Sanghvi * Redistribution and use in source and binary forms, with or 133bdb376eSKumar Sanghvi * without modification, are permitted provided that the following 143bdb376eSKumar Sanghvi * conditions are met: 153bdb376eSKumar Sanghvi * 163bdb376eSKumar Sanghvi * - Redistributions of source code must retain the above 173bdb376eSKumar Sanghvi * copyright notice, this list of conditions and the following 183bdb376eSKumar Sanghvi * disclaimer. 193bdb376eSKumar Sanghvi * 203bdb376eSKumar Sanghvi * - Redistributions in binary form must reproduce the above 213bdb376eSKumar Sanghvi * copyright notice, this list of conditions and the following 223bdb376eSKumar Sanghvi * disclaimer in the documentation and/or other materials 233bdb376eSKumar Sanghvi * provided with the distribution. 243bdb376eSKumar Sanghvi * 253bdb376eSKumar Sanghvi * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 263bdb376eSKumar Sanghvi * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 273bdb376eSKumar Sanghvi * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 283bdb376eSKumar Sanghvi * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 293bdb376eSKumar Sanghvi * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 303bdb376eSKumar Sanghvi * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 313bdb376eSKumar Sanghvi * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 323bdb376eSKumar Sanghvi * SOFTWARE. 333bdb376eSKumar Sanghvi */ 343bdb376eSKumar Sanghvi 353bdb376eSKumar Sanghvi #ifndef __CXGB4_SMT_H 363bdb376eSKumar Sanghvi #define __CXGB4_SMT_H 373bdb376eSKumar Sanghvi 383bdb376eSKumar Sanghvi #include <linux/spinlock.h> 393bdb376eSKumar Sanghvi #include <linux/if_ether.h> 403bdb376eSKumar Sanghvi #include <linux/atomic.h> 413bdb376eSKumar Sanghvi 423bdb376eSKumar Sanghvi struct adapter; 433bdb376eSKumar Sanghvi struct cpl_smt_write_rpl; 443bdb376eSKumar Sanghvi 453bdb376eSKumar Sanghvi /* SMT related handling. Heavily adapted based on l2t ops in l2t.h/l2t.c 463bdb376eSKumar Sanghvi */ 473bdb376eSKumar Sanghvi enum { 483bdb376eSKumar Sanghvi SMT_STATE_SWITCHING, 493bdb376eSKumar Sanghvi SMT_STATE_UNUSED, 503bdb376eSKumar Sanghvi SMT_STATE_ERROR 513bdb376eSKumar Sanghvi }; 523bdb376eSKumar Sanghvi 533bdb376eSKumar Sanghvi enum { 543bdb376eSKumar Sanghvi SMT_SIZE = 256 553bdb376eSKumar Sanghvi }; 563bdb376eSKumar Sanghvi 573bdb376eSKumar Sanghvi struct smt_entry { 583bdb376eSKumar Sanghvi u16 state; 593bdb376eSKumar Sanghvi u16 idx; 603bdb376eSKumar Sanghvi u16 pfvf; 613bdb376eSKumar Sanghvi u8 src_mac[ETH_ALEN]; 62ad2dcba0SChuhong Yuan int refcnt; 633bdb376eSKumar Sanghvi spinlock_t lock; /* protect smt entry add,removal */ 643bdb376eSKumar Sanghvi }; 653bdb376eSKumar Sanghvi 663bdb376eSKumar Sanghvi struct smt_data { 673bdb376eSKumar Sanghvi unsigned int smt_size; 683bdb376eSKumar Sanghvi rwlock_t lock; 69*65dc2f1aSGustavo A. R. Silva struct smt_entry smtab[]; 703bdb376eSKumar Sanghvi }; 713bdb376eSKumar Sanghvi 723bdb376eSKumar Sanghvi struct smt_data *t4_init_smt(void); 733bdb376eSKumar Sanghvi struct smt_entry *cxgb4_smt_alloc_switching(struct net_device *dev, u8 *smac); 743bdb376eSKumar Sanghvi void cxgb4_smt_release(struct smt_entry *e); 753bdb376eSKumar Sanghvi void do_smt_write_rpl(struct adapter *p, const struct cpl_smt_write_rpl *rpl); 763bdb376eSKumar Sanghvi #endif /* __CXGB4_SMT_H */ 77