Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (c) 2016, Mellanox Technologies, Ltd.  All rights reserved.
0003  *
0004  * This software is available to you under a choice of one of two
0005  * licenses.  You may choose to be licensed under the terms of the GNU
0006  * General Public License (GPL) Version 2, available from the file
0007  * COPYING in the main directory of this source tree, or the
0008  * OpenIB.org BSD license below:
0009  *
0010  *     Redistribution and use in source and binary forms, with or
0011  *     without modification, are permitted provided that the following
0012  *     conditions are met:
0013  *
0014  *      - Redistributions of source code must retain the above
0015  *        copyright notice, this list of conditions and the following
0016  *        disclaimer.
0017  *
0018  *      - Redistributions in binary form must reproduce the above
0019  *        copyright notice, this list of conditions and the following
0020  *        disclaimer in the documentation and/or other materials
0021  *        provided with the distribution.
0022  *
0023  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
0024  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
0025  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
0026  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
0027  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
0028  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
0029  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
0030  * SOFTWARE.
0031  */
0032 #ifndef __MLX5_VXLAN_H__
0033 #define __MLX5_VXLAN_H__
0034 
0035 #include <linux/mlx5/driver.h>
0036 
0037 struct mlx5_vxlan;
0038 struct mlx5_vxlan_port;
0039 
0040 static inline u8 mlx5_vxlan_max_udp_ports(struct mlx5_core_dev *mdev)
0041 {
0042     return MLX5_CAP_ETH(mdev, max_vxlan_udp_ports) ?: 4;
0043 }
0044 
0045 static inline bool mlx5_vxlan_allowed(struct mlx5_vxlan *vxlan)
0046 {
0047     /* not allowed reason is encoded in vxlan pointer as error,
0048      * on mlx5_vxlan_create
0049      */
0050     return !IS_ERR_OR_NULL(vxlan);
0051 }
0052 
0053 #if IS_ENABLED(CONFIG_VXLAN)
0054 struct mlx5_vxlan *mlx5_vxlan_create(struct mlx5_core_dev *mdev);
0055 void mlx5_vxlan_destroy(struct mlx5_vxlan *vxlan);
0056 int mlx5_vxlan_add_port(struct mlx5_vxlan *vxlan, u16 port);
0057 int mlx5_vxlan_del_port(struct mlx5_vxlan *vxlan, u16 port);
0058 bool mlx5_vxlan_lookup_port(struct mlx5_vxlan *vxlan, u16 port);
0059 void mlx5_vxlan_reset_to_default(struct mlx5_vxlan *vxlan);
0060 #else
0061 static inline struct mlx5_vxlan*
0062 mlx5_vxlan_create(struct mlx5_core_dev *mdev) { return ERR_PTR(-EOPNOTSUPP); }
0063 static inline void mlx5_vxlan_destroy(struct mlx5_vxlan *vxlan) { return; }
0064 static inline int mlx5_vxlan_add_port(struct mlx5_vxlan *vxlan, u16 port) { return -EOPNOTSUPP; }
0065 static inline int mlx5_vxlan_del_port(struct mlx5_vxlan *vxlan, u16 port) { return -EOPNOTSUPP; }
0066 static inline bool mlx5_vxlan_lookup_port(struct mlx5_vxlan *vxlan, u16 port) { return false; }
0067 static inline void mlx5_vxlan_reset_to_default(struct mlx5_vxlan *vxlan) { return; }
0068 #endif
0069 
0070 #endif /* __MLX5_VXLAN_H__ */