1/*-
2 * Copyright (c) 2013-2017, Mellanox Technologies, Ltd.  All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 *    notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 *    notice, this list of conditions and the following disclaimer in the
11 *    documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS `AS IS' AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 * SUCH DAMAGE.
24 *
25 * $FreeBSD: stable/11/sys/dev/mlx5/vport.h 341972 2018-12-12 13:00:56Z hselasky $
26 */
27
28#ifndef __MLX5_VPORT_H__
29#define __MLX5_VPORT_H__
30
31#include <dev/mlx5/driver.h>
32
33enum {
34	MLX5_CAP_INLINE_MODE_L2,
35	MLX5_CAP_INLINE_MODE_VPORT_CONTEXT,
36	MLX5_CAP_INLINE_MODE_NOT_REQUIRED,
37};
38
39int mlx5_vport_alloc_q_counter(struct mlx5_core_dev *mdev, int client_id,
40			       u16 *counter_set_id);
41int mlx5_vport_dealloc_q_counter(struct mlx5_core_dev *mdev, int client_id,
42				 u16 counter_set_id);
43int mlx5_vport_query_q_counter(struct mlx5_core_dev *mdev,
44			       u16 counter_set_id,
45			       int reset,
46			       void *out,
47			       int out_size);
48int mlx5_vport_query_out_of_rx_buffer(struct mlx5_core_dev *mdev,
49				      u16 counter_set_id,
50				      u32 *out_of_rx_buffer);
51enum mlx5_local_lb_selection {
52	MLX5_LOCAL_MC_LB,
53	MLX5_LOCAL_UC_LB
54};
55
56int mlx5_nic_vport_query_local_lb(struct mlx5_core_dev *mdev,
57				  enum mlx5_local_lb_selection selection,
58				  u8 *value);
59int mlx5_nic_vport_modify_local_lb(struct mlx5_core_dev *mdev,
60				   enum mlx5_local_lb_selection selection,
61				   u8 value);
62u8 mlx5_query_vport_state(struct mlx5_core_dev *mdev, u8 opmod, u16 vport);
63u8 mlx5_query_vport_admin_state(struct mlx5_core_dev *mdev, u8 opmod,
64				u16 vport);
65int mlx5_modify_vport_admin_state(struct mlx5_core_dev *mdev, u8 opmod,
66				  u16 vport, u8 state);
67
68int mlx5_query_vport_mtu(struct mlx5_core_dev *mdev, int *mtu);
69int mlx5_set_vport_mtu(struct mlx5_core_dev *mdev, int mtu);
70int mlx5_query_min_wqe_header(struct mlx5_core_dev *dev, int *min_header);
71int mlx5_set_vport_min_wqe_header(struct mlx5_core_dev *mdev, u8 vport,
72				  int min_header);
73int mlx5_query_nic_vport_promisc(struct mlx5_core_dev *mdev,
74				 u16 vport,
75				 int *promisc_uc,
76				 int *promisc_mc,
77				 int *promisc_all);
78
79int mlx5_modify_nic_vport_promisc(struct mlx5_core_dev *mdev,
80				  int promisc_uc,
81				  int promisc_mc,
82				  int promisc_all);
83int mlx5_query_nic_vport_mac_address(struct mlx5_core_dev *mdev,
84				     u16 vport, u8 *addr);
85int mlx5_modify_nic_vport_mac_address(struct mlx5_core_dev *dev,
86				      u16 vport, u8 mac[ETH_ALEN]);
87int mlx5_set_nic_vport_current_mac(struct mlx5_core_dev *mdev, int vport,
88				   bool other_vport, u8 *addr);
89int mlx5_query_nic_vport_min_inline(struct mlx5_core_dev *mdev,
90				    u16 vport, u8 *min_inline);
91int mlx5_query_min_inline(struct mlx5_core_dev *mdev, u8 *min_inline);
92int mlx5_modify_nic_vport_min_inline(struct mlx5_core_dev *mdev,
93				     u16 vport, u8 min_inline);
94int mlx5_modify_nic_vport_port_guid(struct mlx5_core_dev *mdev,
95				    u32 vport, u64 port_guid);
96int mlx5_modify_nic_vport_node_guid(struct mlx5_core_dev *mdev,
97				    u32 vport, u64 node_guid);
98int mlx5_set_nic_vport_vlan_list(struct mlx5_core_dev *dev, u16 vport,
99				 u16 *vlan_list, int list_len);
100int mlx5_set_nic_vport_mc_list(struct mlx5_core_dev *mdev, int vport,
101			       u64 *addr_list, size_t addr_list_len);
102int mlx5_set_nic_vport_promisc(struct mlx5_core_dev *mdev, int vport,
103			       bool promisc_mc, bool promisc_uc,
104			       bool promisc_all);
105int mlx5_query_nic_vport_mac_list(struct mlx5_core_dev *dev,
106				  u16 vport,
107				  enum mlx5_list_type list_type,
108				  u8 addr_list[][ETH_ALEN],
109				  int *list_size);
110int mlx5_query_nic_vport_vlans(struct mlx5_core_dev *dev,
111			       u16 vport,
112			       u16 vlans[],
113			       int *size);
114int mlx5_modify_nic_vport_vlans(struct mlx5_core_dev *dev,
115				u16 vlans[],
116				int list_size);
117int mlx5_query_nic_vport_roce_en(struct mlx5_core_dev *mdev, u8 *enable);
118int mlx5_modify_nic_vport_mac_list(struct mlx5_core_dev *dev,
119				   enum mlx5_list_type list_type,
120				   u8 addr_list[][ETH_ALEN],
121				   int list_size);
122int mlx5_set_nic_vport_permanent_mac(struct mlx5_core_dev *mdev, int vport,
123				     u8 *addr);
124int mlx5_nic_vport_enable_roce(struct mlx5_core_dev *mdev);
125int mlx5_nic_vport_disable_roce(struct mlx5_core_dev *mdev);
126int mlx5_core_query_vport_counter(struct mlx5_core_dev *dev, u8 other_vport,
127                                  int vf, u8 port_num, void *out,
128                                  size_t out_sz);
129int mlx5_query_nic_vport_system_image_guid(struct mlx5_core_dev *mdev,
130					   u64 *system_image_guid);
131int mlx5_query_vport_system_image_guid(struct mlx5_core_dev *dev,
132				       u64 *sys_image_guid);
133int mlx5_query_vport_node_guid(struct mlx5_core_dev *dev, u64 *node_guid);
134int mlx5_query_vport_port_guid(struct mlx5_core_dev *dev, u64 *port_guid);
135int mlx5_query_hca_vport_state(struct mlx5_core_dev *dev, u8 *vport_state);
136int mlx5_query_nic_vport_node_guid(struct mlx5_core_dev *mdev, u64 *node_guid);
137int mlx5_query_nic_vport_qkey_viol_cntr(struct mlx5_core_dev *mdev,
138					u16 *qkey_viol_cntr);
139int mlx5_query_hca_vport_node_guid(struct mlx5_core_dev *mdev, u64 *node_guid);
140int mlx5_query_hca_vport_system_image_guid(struct mlx5_core_dev *mdev,
141					   u64 *system_image_guid);
142int mlx5_query_hca_vport_context(struct mlx5_core_dev *mdev,
143				 u8 port_num, u8 vport_num, u32 *out,
144				 int outlen);
145int mlx5_query_hca_vport_pkey(struct mlx5_core_dev *dev, u8 other_vport,
146			      u8 port_num, u16 vf_num, u16 pkey_index,
147			      u16 *pkey);
148int mlx5_query_hca_vport_gid(struct mlx5_core_dev *dev, u8 port_num,
149			     u16 vport_num, u16 gid_index, union ib_gid *gid);
150int mlx5_set_eswitch_cvlan_info(struct mlx5_core_dev *mdev, u8 vport,
151				u8 insert_mode, u8 strip_mode,
152				u16 vlan, u8 cfi, u8 pcp);
153int mlx5_query_vport_counter(struct mlx5_core_dev *dev,
154			     u8 port_num, u16 vport_num,
155			     void *out, int out_size);
156int mlx5_get_vport_counters(struct mlx5_core_dev *dev, u8 port_num,
157			    struct mlx5_vport_counters *vc);
158int mlx5_core_query_ib_ppcnt(struct mlx5_core_dev *dev,
159			     u8 port_num, void *out, size_t sz);
160#endif /* __MLX5_VPORT_H__ */
161