1e0c0afd8SArkadi Sharshevsky /* 2e0c0afd8SArkadi Sharshevsky * drivers/net/ethernet/mellanox/mlxsw/spectrum_router.h 3e0c0afd8SArkadi Sharshevsky * Copyright (c) 2017 Mellanox Technologies. All rights reserved. 4e0c0afd8SArkadi Sharshevsky * Copyright (c) 2017 Arkadi Sharshevsky <arkadis@mellanox.com> 5e0c0afd8SArkadi Sharshevsky * 6e0c0afd8SArkadi Sharshevsky * Redistribution and use in source and binary forms, with or without 7e0c0afd8SArkadi Sharshevsky * modification, are permitted provided that the following conditions are met: 8e0c0afd8SArkadi Sharshevsky * 9e0c0afd8SArkadi Sharshevsky * 1. Redistributions of source code must retain the above copyright 10e0c0afd8SArkadi Sharshevsky * notice, this list of conditions and the following disclaimer. 11e0c0afd8SArkadi Sharshevsky * 2. Redistributions in binary form must reproduce the above copyright 12e0c0afd8SArkadi Sharshevsky * notice, this list of conditions and the following disclaimer in the 13e0c0afd8SArkadi Sharshevsky * documentation and/or other materials provided with the distribution. 14e0c0afd8SArkadi Sharshevsky * 3. Neither the names of the copyright holders nor the names of its 15e0c0afd8SArkadi Sharshevsky * contributors may be used to endorse or promote products derived from 16e0c0afd8SArkadi Sharshevsky * this software without specific prior written permission. 17e0c0afd8SArkadi Sharshevsky * 18e0c0afd8SArkadi Sharshevsky * Alternatively, this software may be distributed under the terms of the 19e0c0afd8SArkadi Sharshevsky * GNU General Public License ("GPL") version 2 as published by the Free 20e0c0afd8SArkadi Sharshevsky * Software Foundation. 21e0c0afd8SArkadi Sharshevsky * 22e0c0afd8SArkadi Sharshevsky * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23e0c0afd8SArkadi Sharshevsky * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24e0c0afd8SArkadi Sharshevsky * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25e0c0afd8SArkadi Sharshevsky * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 26e0c0afd8SArkadi Sharshevsky * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27e0c0afd8SArkadi Sharshevsky * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28e0c0afd8SArkadi Sharshevsky * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29e0c0afd8SArkadi Sharshevsky * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30e0c0afd8SArkadi Sharshevsky * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31e0c0afd8SArkadi Sharshevsky * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32e0c0afd8SArkadi Sharshevsky * POSSIBILITY OF SUCH DAMAGE. 33e0c0afd8SArkadi Sharshevsky */ 34e0c0afd8SArkadi Sharshevsky 35e0c0afd8SArkadi Sharshevsky #ifndef _MLXSW_ROUTER_H_ 36e0c0afd8SArkadi Sharshevsky #define _MLXSW_ROUTER_H_ 37e0c0afd8SArkadi Sharshevsky 38e0c0afd8SArkadi Sharshevsky #include "spectrum.h" 39e0c0afd8SArkadi Sharshevsky 40e0c0afd8SArkadi Sharshevsky enum mlxsw_sp_rif_counter_dir { 41e0c0afd8SArkadi Sharshevsky MLXSW_SP_RIF_COUNTER_INGRESS, 42e0c0afd8SArkadi Sharshevsky MLXSW_SP_RIF_COUNTER_EGRESS, 43e0c0afd8SArkadi Sharshevsky }; 44e0c0afd8SArkadi Sharshevsky 45f17cc84dSArkadi Sharshevsky struct mlxsw_sp_neigh_entry; 46f17cc84dSArkadi Sharshevsky 475f9efffbSIdo Schimmel struct mlxsw_sp_rif *mlxsw_sp_rif_by_index(const struct mlxsw_sp *mlxsw_sp, 485f9efffbSIdo Schimmel u16 rif_index); 49fd1b9d41SArkadi Sharshevsky u16 mlxsw_sp_rif_index(const struct mlxsw_sp_rif *rif); 50fd1b9d41SArkadi Sharshevsky int mlxsw_sp_rif_dev_ifindex(const struct mlxsw_sp_rif *rif); 51e0c0afd8SArkadi Sharshevsky int mlxsw_sp_rif_counter_value_get(struct mlxsw_sp *mlxsw_sp, 52e0c0afd8SArkadi Sharshevsky struct mlxsw_sp_rif *rif, 53e0c0afd8SArkadi Sharshevsky enum mlxsw_sp_rif_counter_dir dir, 54e0c0afd8SArkadi Sharshevsky u64 *cnt); 55e0c0afd8SArkadi Sharshevsky void mlxsw_sp_rif_counter_free(struct mlxsw_sp *mlxsw_sp, 56e0c0afd8SArkadi Sharshevsky struct mlxsw_sp_rif *rif, 57e0c0afd8SArkadi Sharshevsky enum mlxsw_sp_rif_counter_dir dir); 58e0c0afd8SArkadi Sharshevsky int mlxsw_sp_rif_counter_alloc(struct mlxsw_sp *mlxsw_sp, 59e0c0afd8SArkadi Sharshevsky struct mlxsw_sp_rif *rif, 60e0c0afd8SArkadi Sharshevsky enum mlxsw_sp_rif_counter_dir dir); 61f17cc84dSArkadi Sharshevsky struct mlxsw_sp_neigh_entry * 62f17cc84dSArkadi Sharshevsky mlxsw_sp_rif_neigh_next(struct mlxsw_sp_rif *rif, 63f17cc84dSArkadi Sharshevsky struct mlxsw_sp_neigh_entry *neigh_entry); 64f17cc84dSArkadi Sharshevsky int mlxsw_sp_neigh_entry_type(struct mlxsw_sp_neigh_entry *neigh_entry); 65f17cc84dSArkadi Sharshevsky unsigned char * 66f17cc84dSArkadi Sharshevsky mlxsw_sp_neigh_entry_ha(struct mlxsw_sp_neigh_entry *neigh_entry); 67f17cc84dSArkadi Sharshevsky u32 mlxsw_sp_neigh4_entry_dip(struct mlxsw_sp_neigh_entry *neigh_entry); 68f17cc84dSArkadi Sharshevsky 69f17cc84dSArkadi Sharshevsky #define mlxsw_sp_rif_neigh_for_each(neigh_entry, rif) \ 70f17cc84dSArkadi Sharshevsky for (neigh_entry = mlxsw_sp_rif_neigh_next(rif, NULL); neigh_entry; \ 71f17cc84dSArkadi Sharshevsky neigh_entry = mlxsw_sp_rif_neigh_next(rif, neigh_entry)) 72*7cfcbc75SArkadi Sharshevsky int mlxsw_sp_neigh_counter_get(struct mlxsw_sp *mlxsw_sp, 73*7cfcbc75SArkadi Sharshevsky struct mlxsw_sp_neigh_entry *neigh_entry, 74*7cfcbc75SArkadi Sharshevsky u64 *p_counter); 75e0c0afd8SArkadi Sharshevsky 76e0c0afd8SArkadi Sharshevsky #endif /* _MLXSW_ROUTER_H_*/ 77