Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (c) 2017, Mellanox Technologies. 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 
0033 #ifndef __MLX5E_IPOB_H__
0034 #define __MLX5E_IPOB_H__
0035 
0036 #ifdef CONFIG_MLX5_CORE_IPOIB
0037 
0038 #include <linux/mlx5/fs.h>
0039 #include "en.h"
0040 
0041 #define MLX5I_MAX_NUM_TC 1
0042 
0043 extern const struct ethtool_ops mlx5i_ethtool_ops;
0044 extern const struct ethtool_ops mlx5i_pkey_ethtool_ops;
0045 extern const struct mlx5e_rx_handlers mlx5i_rx_handlers;
0046 
0047 #define MLX5_IB_GRH_BYTES       40
0048 #define MLX5_IPOIB_ENCAP_LEN    4
0049 #define MLX5_IPOIB_PSEUDO_LEN   20
0050 #define MLX5_IPOIB_HARD_LEN     (MLX5_IPOIB_PSEUDO_LEN + MLX5_IPOIB_ENCAP_LEN)
0051 
0052 /* ipoib rdma netdev's private data structure */
0053 struct mlx5i_priv {
0054     struct rdma_netdev rn; /* keep this first */
0055     u32 qpn;
0056     bool   sub_interface;
0057     u32    qkey;
0058     u16    pkey_index;
0059     struct mlx5i_pkey_qpn_ht *qpn_htbl;
0060     char  *mlx5e_priv[];
0061 };
0062 
0063 int mlx5i_create_tis(struct mlx5_core_dev *mdev, u32 underlay_qpn, u32 *tisn);
0064 
0065 /* Underlay QP create/destroy functions */
0066 int mlx5i_create_underlay_qp(struct mlx5e_priv *priv);
0067 void mlx5i_destroy_underlay_qp(struct mlx5_core_dev *mdev, u32 qpn);
0068 
0069 /* Underlay QP state modification init/uninit functions */
0070 int mlx5i_init_underlay_qp(struct mlx5e_priv *priv);
0071 void mlx5i_uninit_underlay_qp(struct mlx5e_priv *priv);
0072 
0073 /* Allocate/Free underlay QPN to net-device hash table */
0074 int mlx5i_pkey_qpn_ht_init(struct net_device *netdev);
0075 void mlx5i_pkey_qpn_ht_cleanup(struct net_device *netdev);
0076 
0077 /* Add/Remove an underlay QPN to net-device mapping to/from the hash table */
0078 int mlx5i_pkey_add_qpn(struct net_device *netdev, u32 qpn);
0079 int mlx5i_pkey_del_qpn(struct net_device *netdev, u32 qpn);
0080 
0081 /* Get the net-device corresponding to the given underlay QPN */
0082 struct net_device *mlx5i_pkey_get_netdev(struct net_device *netdev, u32 qpn);
0083 
0084 /* Shared ndo functions */
0085 int mlx5i_dev_init(struct net_device *dev);
0086 void mlx5i_dev_cleanup(struct net_device *dev);
0087 int mlx5i_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
0088 
0089 /* Parent profile functions */
0090 int mlx5i_init(struct mlx5_core_dev *mdev, struct net_device *netdev);
0091 void mlx5i_cleanup(struct mlx5e_priv *priv);
0092 
0093 int mlx5i_update_nic_rx(struct mlx5e_priv *priv);
0094 
0095 /* Get child interface nic profile */
0096 const struct mlx5e_profile *mlx5i_pkey_get_profile(void);
0097 
0098 /* Extract mlx5e_priv from IPoIB netdev */
0099 #define mlx5i_epriv(netdev) ((void *)(((struct mlx5i_priv *)netdev_priv(netdev))->mlx5e_priv))
0100 
0101 struct mlx5_wqe_eth_pad {
0102     u8 rsvd0[16];
0103 };
0104 
0105 struct mlx5i_tx_wqe {
0106     struct mlx5_wqe_ctrl_seg     ctrl;
0107     struct mlx5_wqe_datagram_seg datagram;
0108     struct mlx5_wqe_eth_pad      pad;
0109     struct mlx5_wqe_eth_seg      eth;
0110     struct mlx5_wqe_data_seg     data[];
0111 };
0112 
0113 #define MLX5I_SQ_FETCH_WQE(sq, pi) \
0114     ((struct mlx5i_tx_wqe *)mlx5e_fetch_wqe(&(sq)->wq, pi, sizeof(struct mlx5i_tx_wqe)))
0115 
0116 void mlx5i_sq_xmit(struct mlx5e_txqsq *sq, struct sk_buff *skb,
0117            struct mlx5_av *av, u32 dqpn, u32 dqkey, bool xmit_more);
0118 void mlx5i_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats);
0119 
0120 #endif /* CONFIG_MLX5_CORE_IPOIB */
0121 #endif /* __MLX5E_IPOB_H__ */