hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/net/ncsi/internal.h
....@@ -1,10 +1,6 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 /*
23 * Copyright Gavin Shan, IBM Corporation 2016.
3
- *
4
- * This program is free software; you can redistribute it and/or modify
5
- * it under the terms of the GNU General Public License as published by
6
- * the Free Software Foundation; either version 2 of the License, or
7
- * (at your option) any later version.
84 */
95
106 #ifndef __NCSI_INTERNAL_H__
....@@ -67,6 +63,39 @@
6763 NCSI_MODE_FC,
6864 NCSI_MODE_MAX
6965 };
66
+
67
+/* Supported media status bits for Mellanox Mac affinity command.
68
+ * Bit (0-2) for different protocol support; Bit 1 for RBT support,
69
+ * bit 1 for SMBUS support and bit 2 for PCIE support. Bit (3-5)
70
+ * for different protocol availability. Bit 4 for RBT, bit 4 for
71
+ * SMBUS and bit 5 for PCIE.
72
+ */
73
+enum {
74
+ MLX_MC_RBT_SUPPORT = 0x01, /* MC supports RBT */
75
+ MLX_MC_RBT_AVL = 0x08, /* RBT medium is available */
76
+};
77
+
78
+/* OEM Vendor Manufacture ID */
79
+#define NCSI_OEM_MFR_MLX_ID 0x8119
80
+#define NCSI_OEM_MFR_BCM_ID 0x113d
81
+/* Broadcom specific OEM Command */
82
+#define NCSI_OEM_BCM_CMD_GMA 0x01 /* CMD ID for Get MAC */
83
+/* Mellanox specific OEM Command */
84
+#define NCSI_OEM_MLX_CMD_GMA 0x00 /* CMD ID for Get MAC */
85
+#define NCSI_OEM_MLX_CMD_GMA_PARAM 0x1b /* Parameter for GMA */
86
+#define NCSI_OEM_MLX_CMD_SMAF 0x01 /* CMD ID for Set MC Affinity */
87
+#define NCSI_OEM_MLX_CMD_SMAF_PARAM 0x07 /* Parameter for SMAF */
88
+/* OEM Command payload lengths*/
89
+#define NCSI_OEM_BCM_CMD_GMA_LEN 12
90
+#define NCSI_OEM_MLX_CMD_GMA_LEN 8
91
+#define NCSI_OEM_MLX_CMD_SMAF_LEN 60
92
+/* Offset in OEM request */
93
+#define MLX_SMAF_MAC_ADDR_OFFSET 8 /* Offset for MAC in SMAF */
94
+#define MLX_SMAF_MED_SUPPORT_OFFSET 14 /* Offset for medium in SMAF */
95
+/* Mac address offset in OEM response */
96
+#define BCM_MAC_ADDR_OFFSET 28
97
+#define MLX_MAC_ADDR_OFFSET 8
98
+
7099
71100 struct ncsi_channel_version {
72101 u32 version; /* Supported BCD encoded NCSI version */
....@@ -171,6 +200,8 @@
171200 #define NCSI_RESERVED_CHANNEL 0x1f
172201 #define NCSI_CHANNEL_INDEX(c) ((c) & ((1 << NCSI_PACKAGE_SHIFT) - 1))
173202 #define NCSI_TO_CHANNEL(p, c) (((p) << NCSI_PACKAGE_SHIFT) | (c))
203
+#define NCSI_MAX_PACKAGE 8
204
+#define NCSI_MAX_CHANNEL 32
174205
175206 struct ncsi_channel {
176207 unsigned char id;
....@@ -209,6 +240,10 @@
209240 unsigned int channel_num; /* Number of channels */
210241 struct list_head channels; /* List of chanels */
211242 struct list_head node; /* Form list of packages */
243
+
244
+ bool multi_channel; /* Enable multiple channels */
245
+ u32 channel_whitelist; /* Channels to configure */
246
+ struct ncsi_channel *preferred_channel; /* Primary channel */
212247 };
213248
214249 struct ncsi_request {
....@@ -216,11 +251,15 @@
216251 bool used; /* Request that has been assigned */
217252 unsigned int flags; /* NCSI request property */
218253 #define NCSI_REQ_FLAG_EVENT_DRIVEN 1
254
+#define NCSI_REQ_FLAG_NETLINK_DRIVEN 2
219255 struct ncsi_dev_priv *ndp; /* Associated NCSI device */
220256 struct sk_buff *cmd; /* Associated NCSI command packet */
221257 struct sk_buff *rsp; /* Associated NCSI response packet */
222258 struct timer_list timer; /* Timer on waiting for response */
223259 bool enabled; /* Time has been enabled or not */
260
+ u32 snd_seq; /* netlink sending sequence number */
261
+ u32 snd_portid; /* netlink portid of sender */
262
+ struct nlmsghdr nlhdr; /* netlink message header */
224263 };
225264
226265 enum {
....@@ -229,6 +268,8 @@
229268 ncsi_dev_state_probe_deselect = 0x0201,
230269 ncsi_dev_state_probe_package,
231270 ncsi_dev_state_probe_channel,
271
+ ncsi_dev_state_probe_mlx_gma,
272
+ ncsi_dev_state_probe_mlx_smaf,
232273 ncsi_dev_state_probe_cis,
233274 ncsi_dev_state_probe_gvi,
234275 ncsi_dev_state_probe_gc,
....@@ -236,14 +277,13 @@
236277 ncsi_dev_state_probe_dp,
237278 ncsi_dev_state_config_sp = 0x0301,
238279 ncsi_dev_state_config_cis,
280
+ ncsi_dev_state_config_oem_gma,
239281 ncsi_dev_state_config_clear_vids,
240282 ncsi_dev_state_config_svf,
241283 ncsi_dev_state_config_ev,
242284 ncsi_dev_state_config_sma,
243285 ncsi_dev_state_config_ebf,
244
-#if IS_ENABLED(CONFIG_IPV6)
245
- ncsi_dev_state_config_egmf,
246
-#endif
286
+ ncsi_dev_state_config_dgmf,
247287 ncsi_dev_state_config_ecnt,
248288 ncsi_dev_state_config_ec,
249289 ncsi_dev_state_config_ae,
....@@ -269,15 +309,13 @@
269309 #define NCSI_DEV_PROBED 1 /* Finalized NCSI topology */
270310 #define NCSI_DEV_HWA 2 /* Enabled HW arbitration */
271311 #define NCSI_DEV_RESHUFFLE 4
312
+#define NCSI_DEV_RESET 8 /* Reset state of NC */
313
+ unsigned int gma_flag; /* OEM GMA flag */
272314 spinlock_t lock; /* Protect the NCSI device */
273
-#if IS_ENABLED(CONFIG_IPV6)
274
- unsigned int inet6_addr_num; /* Number of IPv6 addresses */
275
-#endif
315
+ unsigned int package_probe_id;/* Current ID during probe */
276316 unsigned int package_num; /* Number of packages */
277317 struct list_head packages; /* List of packages */
278318 struct ncsi_channel *hot_channel; /* Channel was ever active */
279
- struct ncsi_package *force_package; /* Force a specific package */
280
- struct ncsi_channel *force_channel; /* Force a specific channel */
281319 struct ncsi_request requests[256]; /* Request table */
282320 unsigned int request_id; /* Last used request ID */
283321 #define NCSI_REQ_START_IDX 1
....@@ -290,6 +328,10 @@
290328 struct list_head node; /* Form NCSI device list */
291329 #define NCSI_MAX_VLAN_VIDS 15
292330 struct list_head vlan_vids; /* List of active VLAN IDs */
331
+
332
+ bool multi_package; /* Enable multiple packages */
333
+ bool mlx_multi_host; /* Enable multi host Mellanox */
334
+ u32 package_whitelist; /* Packages to configure */
293335 };
294336
295337 struct ncsi_cmd_arg {
....@@ -305,6 +347,8 @@
305347 unsigned short words[8];
306348 unsigned int dwords[4];
307349 };
350
+ unsigned char *data; /* NCSI OEM data */
351
+ struct genl_info *info; /* Netlink information */
308352 };
309353
310354 extern struct list_head ncsi_dev_list;
....@@ -320,6 +364,7 @@
320364 list_for_each_entry_rcu(nc, &np->channels, node)
321365
322366 /* Resources */
367
+int ncsi_reset_dev(struct ncsi_dev *nd);
323368 void ncsi_start_channel_monitor(struct ncsi_channel *nc);
324369 void ncsi_stop_channel_monitor(struct ncsi_channel *nc);
325370 struct ncsi_channel *ncsi_find_channel(struct ncsi_package *np,
....@@ -340,6 +385,13 @@
340385 void ncsi_free_request(struct ncsi_request *nr);
341386 struct ncsi_dev *ncsi_find_dev(struct net_device *dev);
342387 int ncsi_process_next_channel(struct ncsi_dev_priv *ndp);
388
+bool ncsi_channel_has_link(struct ncsi_channel *channel);
389
+bool ncsi_channel_is_last(struct ncsi_dev_priv *ndp,
390
+ struct ncsi_channel *channel);
391
+int ncsi_update_tx_channel(struct ncsi_dev_priv *ndp,
392
+ struct ncsi_package *np,
393
+ struct ncsi_channel *disable,
394
+ struct ncsi_channel *enable);
343395
344396 /* Packet handlers */
345397 u32 ncsi_calculate_checksum(unsigned char *data, int len);