]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c
MFC r294314:
[FreeBSD/stable/10.git] / sys / dev / mlx5 / mlx5_en / mlx5_en_ethtool.c
1 /*-
2  * Copyright (c) 2015 Mellanox Technologies. 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$
26  */
27
28 #include "en.h"
29 #include <net/sff8472.h>
30
31 void
32 mlx5e_create_stats(struct sysctl_ctx_list *ctx,
33     struct sysctl_oid_list *parent, const char *buffer,
34     const char **desc, unsigned num, u64 * arg)
35 {
36         struct sysctl_oid *node;
37         unsigned x;
38
39         sysctl_ctx_init(ctx);
40
41         node = SYSCTL_ADD_NODE(ctx, parent, OID_AUTO,
42             buffer, CTLFLAG_RD, NULL, "Statistics");
43         if (node == NULL)
44                 return;
45         for (x = 0; x != num; x++) {
46                 SYSCTL_ADD_UQUAD(ctx, SYSCTL_CHILDREN(node), OID_AUTO,
47                     desc[2 * x], CTLFLAG_RD, arg + x, desc[2 * x + 1]);
48         }
49 }
50
51 static int
52 mlx5e_ethtool_handler(SYSCTL_HANDLER_ARGS)
53 {
54         struct mlx5e_priv *priv = arg1;
55         uint64_t value;
56         int was_opened;
57         int error;
58
59         PRIV_LOCK(priv);
60         value = priv->params_ethtool.arg[arg2];
61         if (req != NULL) {
62                 error = sysctl_handle_64(oidp, &value, 0, req);
63                 if (error || req->newptr == NULL ||
64                     value == priv->params_ethtool.arg[arg2])
65                         goto done;
66
67                 /* assign new value */
68                 priv->params_ethtool.arg[arg2] = value;
69         } else {
70                 error = 0;
71         }
72         /* check if device is gone */
73         if (priv->gone) {
74                 error = ENXIO;
75                 goto done;
76         }
77         /* import RX coal time */
78         if (priv->params_ethtool.rx_coalesce_usecs < 1)
79                 priv->params_ethtool.rx_coalesce_usecs = 0;
80         else if (priv->params_ethtool.rx_coalesce_usecs >
81             MLX5E_FLD_MAX(cqc, cq_period)) {
82                 priv->params_ethtool.rx_coalesce_usecs =
83                     MLX5E_FLD_MAX(cqc, cq_period);
84         }
85         priv->params.rx_cq_moderation_usec = priv->params_ethtool.rx_coalesce_usecs;
86
87         /* import RX coal pkts */
88         if (priv->params_ethtool.rx_coalesce_pkts < 1)
89                 priv->params_ethtool.rx_coalesce_pkts = 0;
90         else if (priv->params_ethtool.rx_coalesce_pkts >
91             MLX5E_FLD_MAX(cqc, cq_max_count)) {
92                 priv->params_ethtool.rx_coalesce_pkts =
93                     MLX5E_FLD_MAX(cqc, cq_max_count);
94         }
95         priv->params.rx_cq_moderation_pkts = priv->params_ethtool.rx_coalesce_pkts;
96
97         /* import TX coal time */
98         if (priv->params_ethtool.tx_coalesce_usecs < 1)
99                 priv->params_ethtool.tx_coalesce_usecs = 0;
100         else if (priv->params_ethtool.tx_coalesce_usecs >
101             MLX5E_FLD_MAX(cqc, cq_period)) {
102                 priv->params_ethtool.tx_coalesce_usecs =
103                     MLX5E_FLD_MAX(cqc, cq_period);
104         }
105         priv->params.tx_cq_moderation_usec = priv->params_ethtool.tx_coalesce_usecs;
106
107         /* import TX coal pkts */
108         if (priv->params_ethtool.tx_coalesce_pkts < 1)
109                 priv->params_ethtool.tx_coalesce_pkts = 0;
110         else if (priv->params_ethtool.tx_coalesce_pkts >
111             MLX5E_FLD_MAX(cqc, cq_max_count)) {
112                 priv->params_ethtool.tx_coalesce_pkts = MLX5E_FLD_MAX(cqc, cq_max_count);
113         }
114         priv->params.tx_cq_moderation_pkts = priv->params_ethtool.tx_coalesce_pkts;
115
116         was_opened = test_bit(MLX5E_STATE_OPENED, &priv->state);
117         if (was_opened) {
118                 u64 *xarg = priv->params_ethtool.arg + arg2;
119
120                 if (xarg == &priv->params_ethtool.tx_coalesce_pkts ||
121                     xarg == &priv->params_ethtool.rx_coalesce_pkts ||
122                     xarg == &priv->params_ethtool.tx_coalesce_usecs ||
123                     xarg == &priv->params_ethtool.rx_coalesce_usecs) {
124                         /* avoid downing and upping the network interface */
125                         error = mlx5e_refresh_channel_params(priv);
126                         goto done;
127                 }
128                 mlx5e_close_locked(priv->ifp);
129         }
130         /* import TX queue size */
131         if (priv->params_ethtool.tx_queue_size <
132             (1 << MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE)) {
133                 priv->params_ethtool.tx_queue_size =
134                     (1 << MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE);
135         } else if (priv->params_ethtool.tx_queue_size >
136             priv->params_ethtool.tx_queue_size_max) {
137                 priv->params_ethtool.tx_queue_size =
138                     priv->params_ethtool.tx_queue_size_max;
139         }
140         priv->params.log_sq_size =
141             order_base_2(priv->params_ethtool.tx_queue_size);
142
143         /* import RX queue size */
144         if (priv->params_ethtool.rx_queue_size <
145             (1 << MLX5E_PARAMS_MINIMUM_LOG_RQ_SIZE)) {
146                 priv->params_ethtool.rx_queue_size =
147                     (1 << MLX5E_PARAMS_MINIMUM_LOG_RQ_SIZE);
148         } else if (priv->params_ethtool.rx_queue_size >
149             priv->params_ethtool.rx_queue_size_max) {
150                 priv->params_ethtool.rx_queue_size =
151                     priv->params_ethtool.rx_queue_size_max;
152         }
153         priv->params.log_rq_size =
154             order_base_2(priv->params_ethtool.rx_queue_size);
155
156         priv->params.min_rx_wqes = min_t (u16,
157                   priv->params_ethtool.rx_queue_size - 1,
158                   MLX5E_PARAMS_DEFAULT_MIN_RX_WQES);
159
160         /* import number of channels */
161         if (priv->params_ethtool.channels < 1)
162                 priv->params_ethtool.channels = 1;
163         else if (priv->params_ethtool.channels >
164             (u64) priv->mdev->priv.eq_table.num_comp_vectors) {
165                 priv->params_ethtool.channels =
166                     (u64) priv->mdev->priv.eq_table.num_comp_vectors;
167         }
168         priv->params.num_channels = priv->params_ethtool.channels;
169
170         /* import RX mode */
171         if (priv->params_ethtool.rx_coalesce_mode != 0)
172                 priv->params_ethtool.rx_coalesce_mode = 1;
173         priv->params.rx_cq_moderation_mode = priv->params_ethtool.rx_coalesce_mode;
174
175         /* import TX mode */
176         if (priv->params_ethtool.tx_coalesce_mode != 0)
177                 priv->params_ethtool.tx_coalesce_mode = 1;
178         priv->params.tx_cq_moderation_mode = priv->params_ethtool.tx_coalesce_mode;
179
180         /* we always agree to turn off HW LRO - but not always to turn on */
181         if (priv->params_ethtool.hw_lro) {
182                 if (priv->params_ethtool.hw_lro != 1) {
183                         priv->params_ethtool.hw_lro = priv->params.hw_lro_en;
184                         error = EINVAL;
185                         goto done;
186                 }
187                 if (priv->ifp->if_capenable & IFCAP_LRO)
188                         priv->params.hw_lro_en = !!MLX5_CAP_ETH(priv->mdev, lro_cap);
189                 else {
190                         /* set the correct (0) value to params_ethtool.hw_lro, issue a warning and return error */
191                         priv->params_ethtool.hw_lro = 0;
192                         error = EINVAL;
193                         if_printf(priv->ifp, "Can't set HW_LRO to a device with LRO turned off");
194                         goto done;
195                 }
196         } else {
197                 priv->params.hw_lro_en = false;
198         }
199
200         if (&priv->params_ethtool.arg[arg2] ==
201             &priv->params_ethtool.cqe_zipping) {
202                 if (priv->params_ethtool.cqe_zipping &&
203                     MLX5_CAP_GEN(priv->mdev, cqe_compression)) {
204                         priv->params.cqe_zipping_en = true;
205                         priv->params_ethtool.cqe_zipping = 1;
206                 } else {
207                         priv->params.cqe_zipping_en = false;
208                         priv->params_ethtool.cqe_zipping = 0;
209                 }
210         }
211
212         if (was_opened)
213                 mlx5e_open_locked(priv->ifp);
214 done:
215         PRIV_UNLOCK(priv);
216         return (error);
217 }
218
219 /*
220  * Read the first three bytes of the eeprom in order to get the needed info
221  * for the whole reading.
222  * Byte 0 - Identifier byte
223  * Byte 1 - Revision byte
224  * Byte 2 - Status byte
225  */
226 static int
227 mlx5e_get_eeprom_info(struct mlx5e_priv *priv, struct mlx5e_eeprom *eeprom)
228 {
229         struct mlx5_core_dev *dev = priv->mdev;
230         u32 data = 0;
231         int size_read = 0;
232         int ret;
233
234         ret = mlx5_query_module_num(dev, &eeprom->module_num);
235         if (ret) {
236                 if_printf(priv->ifp, "%s:%d: Failed query module error=%d\n",
237                     __func__, __LINE__, ret);
238                 return (ret);
239         }
240
241         /* Read the first three bytes to get Identifier, Revision and Status */
242         ret = mlx5_query_eeprom(dev, eeprom->i2c_addr, eeprom->page_num,
243             eeprom->device_addr, MLX5E_EEPROM_INFO_BYTES, eeprom->module_num, &data,
244             &size_read);
245         if (ret) {
246                 if_printf(priv->ifp, "%s:%d: Failed query eeprom module error=0x%x\n",
247                     __func__, __LINE__, ret);
248                 return (ret);
249         }
250
251         switch (data & MLX5_EEPROM_IDENTIFIER_BYTE_MASK) {
252         case SFF_8024_ID_QSFP:
253                 eeprom->type = MLX5E_ETH_MODULE_SFF_8436;
254                 eeprom->len = MLX5E_ETH_MODULE_SFF_8436_LEN;
255                 break;
256         case SFF_8024_ID_QSFPPLUS:
257         case SFF_8024_ID_QSFP28:
258                 if ((data & MLX5_EEPROM_IDENTIFIER_BYTE_MASK) == SFF_8024_ID_QSFP28 ||
259                     ((data & MLX5_EEPROM_REVISION_ID_BYTE_MASK) >> 8) >= 0x3) {
260                         eeprom->type = MLX5E_ETH_MODULE_SFF_8636;
261                         eeprom->len = MLX5E_ETH_MODULE_SFF_8636_LEN;
262                 } else {
263                         eeprom->type = MLX5E_ETH_MODULE_SFF_8436;
264                         eeprom->len = MLX5E_ETH_MODULE_SFF_8436_LEN;
265                 }
266                 if ((data & MLX5_EEPROM_PAGE_3_VALID_BIT_MASK) == 0)
267                         eeprom->page_valid = 1;
268                 break;
269         case SFF_8024_ID_SFP:
270                 eeprom->type = MLX5E_ETH_MODULE_SFF_8472;
271                 eeprom->len = MLX5E_ETH_MODULE_SFF_8472_LEN;
272                 break;
273         default:
274                 if_printf(priv->ifp, "%s:%d: Not recognized cable type = 0x%x(%s)\n",
275                     __func__, __LINE__, data & MLX5_EEPROM_IDENTIFIER_BYTE_MASK,
276                     sff_8024_id[data & MLX5_EEPROM_IDENTIFIER_BYTE_MASK]);
277                 return (EINVAL);
278         }
279         return (0);
280 }
281
282 /* Read both low and high pages of the eeprom */
283 static int
284 mlx5e_get_eeprom(struct mlx5e_priv *priv, struct mlx5e_eeprom *ee)
285 {
286         struct mlx5_core_dev *dev = priv->mdev;
287         int size_read = 0;
288         int ret;
289
290         if (ee->len == 0)
291                 return (EINVAL);
292
293         /* Read low page of the eeprom */
294         while (ee->device_addr < ee->len) {
295                 ret = mlx5_query_eeprom(dev, ee->i2c_addr, ee->page_num, ee->device_addr,
296                     ee->len - ee->device_addr, ee->module_num,
297                     ee->data + (ee->device_addr / 4), &size_read);
298                 if (ret) {
299                         if_printf(priv->ifp, "%s:%d: Failed reading eeprom, "
300                             "error = 0x%02x\n", __func__, __LINE__, ret);
301                         return (ret);
302                 }
303                 ee->device_addr += size_read;
304         }
305
306         /* Read high page of the eeprom */
307         if (ee->page_valid) {
308                 ee->device_addr = MLX5E_EEPROM_HIGH_PAGE_OFFSET;
309                 ee->page_num = MLX5E_EEPROM_HIGH_PAGE;
310                 size_read = 0;
311                 while (ee->device_addr < MLX5E_EEPROM_PAGE_LENGTH) {
312                         ret = mlx5_query_eeprom(dev, ee->i2c_addr, ee->page_num,
313                             ee->device_addr, MLX5E_EEPROM_PAGE_LENGTH - ee->device_addr,
314                             ee->module_num, ee->data + (ee->len / 4) +
315                             ((ee->device_addr - MLX5E_EEPROM_HIGH_PAGE_OFFSET) / 4),
316                             &size_read);
317                         if (ret) {
318                                 if_printf(priv->ifp, "%s:%d: Failed reading eeprom, "
319                                     "error = 0x%02x\n", __func__, __LINE__, ret);
320                                 return (ret);
321                         }
322                         ee->device_addr += size_read;
323                 }
324         }
325         return (0);
326 }
327
328 static void
329 mlx5e_print_eeprom(struct mlx5e_eeprom *eeprom)
330 {
331         int row;
332         int index_in_row;
333         int byte_to_write = 0;
334         int line_length = 16;
335
336         printf("\nOffset\t\tValues\n");
337         printf("------\t\t------");
338         while (byte_to_write < eeprom->len) {
339                 printf("\n0x%04X\t\t", byte_to_write);
340                 for (index_in_row = 0; index_in_row < line_length; index_in_row++) {
341                         printf("%02X ", ((u8 *)eeprom->data)[byte_to_write]);
342                         byte_to_write++;
343                 }
344         }
345
346         if (eeprom->page_valid) {
347                 row = MLX5E_EEPROM_HIGH_PAGE_OFFSET;
348                 printf("\n\nUpper Page 0x03\n");
349                 printf("\nOffset\t\tValues\n");
350                 printf("------\t\t------");
351                 while (row < MLX5E_EEPROM_PAGE_LENGTH) {
352                         printf("\n0x%04X\t\t", row);
353                         for (index_in_row = 0; index_in_row < line_length; index_in_row++) {
354                                 printf("%02X ", ((u8 *)eeprom->data)[byte_to_write]);
355                                 byte_to_write++;
356                                 row++;
357                         }
358                 }
359         }
360 }
361
362 /*
363  * Read cable EEPROM module information by first inspecting the first
364  * three bytes to get the initial information for a whole reading.
365  * Information will be printed to dmesg.
366  */
367 static int
368 mlx5e_read_eeprom(SYSCTL_HANDLER_ARGS)
369 {
370         struct mlx5e_priv *priv = arg1;
371         struct mlx5e_eeprom eeprom;
372         int error;
373         int result = 0;
374
375         PRIV_LOCK(priv);
376         error = sysctl_handle_int(oidp, &result, 0, req);
377         if (error || !req->newptr)
378                 goto done;
379
380         /* Check if device is gone */
381         if (priv->gone) {
382                 error = ENXIO;
383                 goto done;
384         }
385
386         if (result == 1) {
387                 eeprom.i2c_addr = MLX5E_I2C_ADDR_LOW;
388                 eeprom.device_addr = 0;
389                 eeprom.page_num = MLX5E_EEPROM_LOW_PAGE;
390                 eeprom.page_valid = 0;
391
392                 /* Read three first bytes to get important info */
393                 error = mlx5e_get_eeprom_info(priv, &eeprom);
394                 if (error) {
395                         if_printf(priv->ifp, "%s:%d: Failed reading eeprom's "
396                             "initial information\n", __func__, __LINE__);
397                         error = 0;
398                         goto done;
399                 }
400                 /*
401                  * Allocate needed length buffer and additional space for
402                  * page 0x03
403                  */
404                 eeprom.data = malloc(eeprom.len + MLX5E_EEPROM_PAGE_LENGTH,
405                     M_MLX5EN, M_WAITOK | M_ZERO);
406
407                 /* Read the whole eeprom information */
408                 error = mlx5e_get_eeprom(priv, &eeprom);
409                 if (error) {
410                         if_printf(priv->ifp, "%s:%d: Failed reading eeprom\n",
411                             __func__, __LINE__);
412                         error = 0;
413                         /*
414                          * Continue printing partial information in case of
415                          * an error
416                          */
417                 }
418                 mlx5e_print_eeprom(&eeprom);
419                 free(eeprom.data, M_MLX5EN);
420         }
421 done:
422         PRIV_UNLOCK(priv);
423         return (error);
424 }
425
426 static const char *mlx5e_params_desc[] = {
427         MLX5E_PARAMS(MLX5E_STATS_DESC)
428 };
429
430 static const char *mlx5e_port_stats_debug_desc[] = {
431         MLX5E_PORT_STATS_DEBUG(MLX5E_STATS_DESC)
432 };
433
434 static int
435 mlx5e_ethtool_debug_stats(SYSCTL_HANDLER_ARGS)
436 {
437         struct mlx5e_priv *priv = arg1;
438         int error;
439         int sys_debug;
440
441         sys_debug = priv->sysctl_debug;
442         error = sysctl_handle_int(oidp, &priv->sysctl_debug, 0, req);
443         if (error || !req->newptr)
444                 return (error);
445         priv->sysctl_debug = !!priv->sysctl_debug;
446         if (sys_debug == priv->sysctl_debug)
447                 return (error);
448         if (priv->sysctl_debug)
449                 mlx5e_create_stats(&priv->stats.port_stats_debug.ctx,
450                     SYSCTL_CHILDREN(priv->sysctl_ifnet), "debug_stats",
451                     mlx5e_port_stats_debug_desc, MLX5E_PORT_STATS_DEBUG_NUM,
452                     priv->stats.port_stats_debug.arg);
453         else
454                 sysctl_ctx_free(&priv->stats.port_stats_debug.ctx);
455         return (error);
456 }
457
458 void
459 mlx5e_create_ethtool(struct mlx5e_priv *priv)
460 {
461         struct sysctl_oid *node;
462         const char *pnameunit;
463         unsigned x;
464
465         /* set some defaults */
466         priv->params_ethtool.tx_queue_size_max = 1 << MLX5E_PARAMS_MAXIMUM_LOG_SQ_SIZE;
467         priv->params_ethtool.rx_queue_size_max = 1 << MLX5E_PARAMS_MAXIMUM_LOG_RQ_SIZE;
468         priv->params_ethtool.tx_queue_size = 1 << priv->params.log_sq_size;
469         priv->params_ethtool.rx_queue_size = 1 << priv->params.log_rq_size;
470         priv->params_ethtool.channels = priv->params.num_channels;
471         priv->params_ethtool.coalesce_pkts_max = MLX5E_FLD_MAX(cqc, cq_max_count);
472         priv->params_ethtool.coalesce_usecs_max = MLX5E_FLD_MAX(cqc, cq_period);
473         priv->params_ethtool.rx_coalesce_mode = priv->params.rx_cq_moderation_mode;
474         priv->params_ethtool.rx_coalesce_usecs = priv->params.rx_cq_moderation_usec;
475         priv->params_ethtool.rx_coalesce_pkts = priv->params.rx_cq_moderation_pkts;
476         priv->params_ethtool.tx_coalesce_mode = priv->params.tx_cq_moderation_mode;
477         priv->params_ethtool.tx_coalesce_usecs = priv->params.tx_cq_moderation_usec;
478         priv->params_ethtool.tx_coalesce_pkts = priv->params.tx_cq_moderation_pkts;
479         priv->params_ethtool.hw_lro = priv->params.hw_lro_en;
480         priv->params_ethtool.cqe_zipping = priv->params.cqe_zipping_en;
481
482         /* create root node */
483         node = SYSCTL_ADD_NODE(&priv->sysctl_ctx,
484             SYSCTL_CHILDREN(priv->sysctl_ifnet), OID_AUTO,
485             "conf", CTLFLAG_RW, NULL, "Configuration");
486         if (node == NULL)
487                 return;
488         for (x = 0; x != MLX5E_PARAMS_NUM; x++) {
489                 /* check for read-only parameter */
490                 if (strstr(mlx5e_params_desc[2 * x], "_max") != NULL) {
491                         SYSCTL_ADD_PROC(&priv->sysctl_ctx, SYSCTL_CHILDREN(node), OID_AUTO,
492                             mlx5e_params_desc[2 * x], CTLTYPE_U64 | CTLFLAG_RD |
493                             CTLFLAG_MPSAFE, priv, x, &mlx5e_ethtool_handler, "QU",
494                             mlx5e_params_desc[2 * x + 1]);
495                 } else {
496 #if (__FreeBSD_version < 1100000)
497                         char path[64];
498 #endif
499                         /*
500                          * NOTE: In FreeBSD-11 and newer the
501                          * CTLFLAG_RWTUN flag will take care of
502                          * loading default sysctl value from the
503                          * kernel environment, if any:
504                          */
505                         SYSCTL_ADD_PROC(&priv->sysctl_ctx, SYSCTL_CHILDREN(node), OID_AUTO,
506                             mlx5e_params_desc[2 * x], CTLTYPE_U64 | CTLFLAG_RWTUN |
507                             CTLFLAG_MPSAFE, priv, x, &mlx5e_ethtool_handler, "QU",
508                             mlx5e_params_desc[2 * x + 1]);
509
510 #if (__FreeBSD_version < 1100000)
511                         /* compute path for sysctl */
512                         snprintf(path, sizeof(path), "dev.mce.%d.conf.%s",
513                             device_get_unit(priv->mdev->pdev->dev.bsddev),
514                             mlx5e_params_desc[2 * x]);
515
516                         /* try to fetch tunable, if any */
517                         if (TUNABLE_QUAD_FETCH(path, &priv->params_ethtool.arg[x]))
518                                 mlx5e_ethtool_handler(NULL, priv, x, NULL);
519 #endif
520                 }
521         }
522
523         SYSCTL_ADD_PROC(&priv->sysctl_ctx, SYSCTL_CHILDREN(node), OID_AUTO,
524             "debug_stats", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, priv,
525             0, &mlx5e_ethtool_debug_stats, "I", "Extended debug statistics");
526
527         pnameunit = device_get_nameunit(priv->mdev->pdev->dev.bsddev);
528
529         SYSCTL_ADD_STRING(&priv->sysctl_ctx, SYSCTL_CHILDREN(node),
530             OID_AUTO, "device_name", CTLFLAG_RD,
531             __DECONST(void *, pnameunit), 0,
532             "PCI device name");
533
534         /* EEPROM support */
535         SYSCTL_ADD_PROC(&priv->sysctl_ctx, SYSCTL_CHILDREN(node), OID_AUTO, "eeprom_info",
536             CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, priv, 0,
537             mlx5e_read_eeprom, "I", "EEPROM information");
538 }