18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright (c) 2016, Mellanox Technologies. All rights reserved. 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * This software is available to you under a choice of one of two 58c2ecf20Sopenharmony_ci * licenses. You may choose to be licensed under the terms of the GNU 68c2ecf20Sopenharmony_ci * General Public License (GPL) Version 2, available from the file 78c2ecf20Sopenharmony_ci * COPYING in the main directory of this source tree, or the 88c2ecf20Sopenharmony_ci * OpenIB.org BSD license below: 98c2ecf20Sopenharmony_ci * 108c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or 118c2ecf20Sopenharmony_ci * without modification, are permitted provided that the following 128c2ecf20Sopenharmony_ci * conditions are met: 138c2ecf20Sopenharmony_ci * 148c2ecf20Sopenharmony_ci * - Redistributions of source code must retain the above 158c2ecf20Sopenharmony_ci * copyright notice, this list of conditions and the following 168c2ecf20Sopenharmony_ci * disclaimer. 178c2ecf20Sopenharmony_ci * 188c2ecf20Sopenharmony_ci * - Redistributions in binary form must reproduce the above 198c2ecf20Sopenharmony_ci * copyright notice, this list of conditions and the following 208c2ecf20Sopenharmony_ci * disclaimer in the documentation and/or other materials 218c2ecf20Sopenharmony_ci * provided with the distribution. 228c2ecf20Sopenharmony_ci * 238c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 248c2ecf20Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 258c2ecf20Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 268c2ecf20Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 278c2ecf20Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 288c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 298c2ecf20Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 308c2ecf20Sopenharmony_ci * SOFTWARE. 318c2ecf20Sopenharmony_ci */ 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci#ifndef __MLX5_PORT_H__ 348c2ecf20Sopenharmony_ci#define __MLX5_PORT_H__ 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci#include <linux/mlx5/driver.h> 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_cienum mlx5_beacon_duration { 398c2ecf20Sopenharmony_ci MLX5_BEACON_DURATION_OFF = 0x0, 408c2ecf20Sopenharmony_ci MLX5_BEACON_DURATION_INF = 0xffff, 418c2ecf20Sopenharmony_ci}; 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_cienum mlx5_module_id { 448c2ecf20Sopenharmony_ci MLX5_MODULE_ID_SFP = 0x3, 458c2ecf20Sopenharmony_ci MLX5_MODULE_ID_QSFP = 0xC, 468c2ecf20Sopenharmony_ci MLX5_MODULE_ID_QSFP_PLUS = 0xD, 478c2ecf20Sopenharmony_ci MLX5_MODULE_ID_QSFP28 = 0x11, 488c2ecf20Sopenharmony_ci}; 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_cienum mlx5_an_status { 518c2ecf20Sopenharmony_ci MLX5_AN_UNAVAILABLE = 0, 528c2ecf20Sopenharmony_ci MLX5_AN_COMPLETE = 1, 538c2ecf20Sopenharmony_ci MLX5_AN_FAILED = 2, 548c2ecf20Sopenharmony_ci MLX5_AN_LINK_UP = 3, 558c2ecf20Sopenharmony_ci MLX5_AN_LINK_DOWN = 4, 568c2ecf20Sopenharmony_ci}; 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci#define MLX5_EEPROM_MAX_BYTES 32 598c2ecf20Sopenharmony_ci#define MLX5_EEPROM_IDENTIFIER_BYTE_MASK 0x000000ff 608c2ecf20Sopenharmony_ci#define MLX5_I2C_ADDR_LOW 0x50 618c2ecf20Sopenharmony_ci#define MLX5_I2C_ADDR_HIGH 0x51 628c2ecf20Sopenharmony_ci#define MLX5_EEPROM_PAGE_LENGTH 256 638c2ecf20Sopenharmony_ci#define MLX5_EEPROM_HIGH_PAGE_LENGTH 128 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_cienum mlx5e_link_mode { 668c2ecf20Sopenharmony_ci MLX5E_1000BASE_CX_SGMII = 0, 678c2ecf20Sopenharmony_ci MLX5E_1000BASE_KX = 1, 688c2ecf20Sopenharmony_ci MLX5E_10GBASE_CX4 = 2, 698c2ecf20Sopenharmony_ci MLX5E_10GBASE_KX4 = 3, 708c2ecf20Sopenharmony_ci MLX5E_10GBASE_KR = 4, 718c2ecf20Sopenharmony_ci MLX5E_20GBASE_KR2 = 5, 728c2ecf20Sopenharmony_ci MLX5E_40GBASE_CR4 = 6, 738c2ecf20Sopenharmony_ci MLX5E_40GBASE_KR4 = 7, 748c2ecf20Sopenharmony_ci MLX5E_56GBASE_R4 = 8, 758c2ecf20Sopenharmony_ci MLX5E_10GBASE_CR = 12, 768c2ecf20Sopenharmony_ci MLX5E_10GBASE_SR = 13, 778c2ecf20Sopenharmony_ci MLX5E_10GBASE_ER = 14, 788c2ecf20Sopenharmony_ci MLX5E_40GBASE_SR4 = 15, 798c2ecf20Sopenharmony_ci MLX5E_40GBASE_LR4 = 16, 808c2ecf20Sopenharmony_ci MLX5E_50GBASE_SR2 = 18, 818c2ecf20Sopenharmony_ci MLX5E_100GBASE_CR4 = 20, 828c2ecf20Sopenharmony_ci MLX5E_100GBASE_SR4 = 21, 838c2ecf20Sopenharmony_ci MLX5E_100GBASE_KR4 = 22, 848c2ecf20Sopenharmony_ci MLX5E_100GBASE_LR4 = 23, 858c2ecf20Sopenharmony_ci MLX5E_100BASE_TX = 24, 868c2ecf20Sopenharmony_ci MLX5E_1000BASE_T = 25, 878c2ecf20Sopenharmony_ci MLX5E_10GBASE_T = 26, 888c2ecf20Sopenharmony_ci MLX5E_25GBASE_CR = 27, 898c2ecf20Sopenharmony_ci MLX5E_25GBASE_KR = 28, 908c2ecf20Sopenharmony_ci MLX5E_25GBASE_SR = 29, 918c2ecf20Sopenharmony_ci MLX5E_50GBASE_CR2 = 30, 928c2ecf20Sopenharmony_ci MLX5E_50GBASE_KR2 = 31, 938c2ecf20Sopenharmony_ci MLX5E_LINK_MODES_NUMBER, 948c2ecf20Sopenharmony_ci}; 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_cienum mlx5e_ext_link_mode { 978c2ecf20Sopenharmony_ci MLX5E_SGMII_100M = 0, 988c2ecf20Sopenharmony_ci MLX5E_1000BASE_X_SGMII = 1, 998c2ecf20Sopenharmony_ci MLX5E_5GBASE_R = 3, 1008c2ecf20Sopenharmony_ci MLX5E_10GBASE_XFI_XAUI_1 = 4, 1018c2ecf20Sopenharmony_ci MLX5E_40GBASE_XLAUI_4_XLPPI_4 = 5, 1028c2ecf20Sopenharmony_ci MLX5E_25GAUI_1_25GBASE_CR_KR = 6, 1038c2ecf20Sopenharmony_ci MLX5E_50GAUI_2_LAUI_2_50GBASE_CR2_KR2 = 7, 1048c2ecf20Sopenharmony_ci MLX5E_50GAUI_1_LAUI_1_50GBASE_CR_KR = 8, 1058c2ecf20Sopenharmony_ci MLX5E_CAUI_4_100GBASE_CR4_KR4 = 9, 1068c2ecf20Sopenharmony_ci MLX5E_100GAUI_2_100GBASE_CR2_KR2 = 10, 1078c2ecf20Sopenharmony_ci MLX5E_100GAUI_1_100GBASE_CR_KR = 11, 1088c2ecf20Sopenharmony_ci MLX5E_200GAUI_4_200GBASE_CR4_KR4 = 12, 1098c2ecf20Sopenharmony_ci MLX5E_200GAUI_2_200GBASE_CR2_KR2 = 13, 1108c2ecf20Sopenharmony_ci MLX5E_400GAUI_8 = 15, 1118c2ecf20Sopenharmony_ci MLX5E_400GAUI_4_400GBASE_CR4_KR4 = 16, 1128c2ecf20Sopenharmony_ci MLX5E_EXT_LINK_MODES_NUMBER, 1138c2ecf20Sopenharmony_ci}; 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_cienum mlx5e_connector_type { 1168c2ecf20Sopenharmony_ci MLX5E_PORT_UNKNOWN = 0, 1178c2ecf20Sopenharmony_ci MLX5E_PORT_NONE = 1, 1188c2ecf20Sopenharmony_ci MLX5E_PORT_TP = 2, 1198c2ecf20Sopenharmony_ci MLX5E_PORT_AUI = 3, 1208c2ecf20Sopenharmony_ci MLX5E_PORT_BNC = 4, 1218c2ecf20Sopenharmony_ci MLX5E_PORT_MII = 5, 1228c2ecf20Sopenharmony_ci MLX5E_PORT_FIBRE = 6, 1238c2ecf20Sopenharmony_ci MLX5E_PORT_DA = 7, 1248c2ecf20Sopenharmony_ci MLX5E_PORT_OTHER = 8, 1258c2ecf20Sopenharmony_ci MLX5E_CONNECTOR_TYPE_NUMBER, 1268c2ecf20Sopenharmony_ci}; 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_cienum mlx5_ptys_width { 1298c2ecf20Sopenharmony_ci MLX5_PTYS_WIDTH_1X = 1 << 0, 1308c2ecf20Sopenharmony_ci MLX5_PTYS_WIDTH_2X = 1 << 1, 1318c2ecf20Sopenharmony_ci MLX5_PTYS_WIDTH_4X = 1 << 2, 1328c2ecf20Sopenharmony_ci MLX5_PTYS_WIDTH_8X = 1 << 3, 1338c2ecf20Sopenharmony_ci MLX5_PTYS_WIDTH_12X = 1 << 4, 1348c2ecf20Sopenharmony_ci}; 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_ci#define MLX5E_PROT_MASK(link_mode) (1 << link_mode) 1378c2ecf20Sopenharmony_ci#define MLX5_GET_ETH_PROTO(reg, out, ext, field) \ 1388c2ecf20Sopenharmony_ci (ext ? MLX5_GET(reg, out, ext_##field) : \ 1398c2ecf20Sopenharmony_ci MLX5_GET(reg, out, field)) 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_ciint mlx5_set_port_caps(struct mlx5_core_dev *dev, u8 port_num, u32 caps); 1428c2ecf20Sopenharmony_ciint mlx5_query_port_ptys(struct mlx5_core_dev *dev, u32 *ptys, 1438c2ecf20Sopenharmony_ci int ptys_size, int proto_mask, u8 local_port); 1448c2ecf20Sopenharmony_ci 1458c2ecf20Sopenharmony_ciint mlx5_query_ib_port_oper(struct mlx5_core_dev *dev, u16 *link_width_oper, 1468c2ecf20Sopenharmony_ci u16 *proto_oper, u8 local_port); 1478c2ecf20Sopenharmony_civoid mlx5_toggle_port_link(struct mlx5_core_dev *dev); 1488c2ecf20Sopenharmony_ciint mlx5_set_port_admin_status(struct mlx5_core_dev *dev, 1498c2ecf20Sopenharmony_ci enum mlx5_port_status status); 1508c2ecf20Sopenharmony_ciint mlx5_query_port_admin_status(struct mlx5_core_dev *dev, 1518c2ecf20Sopenharmony_ci enum mlx5_port_status *status); 1528c2ecf20Sopenharmony_ciint mlx5_set_port_beacon(struct mlx5_core_dev *dev, u16 beacon_duration); 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_ciint mlx5_set_port_mtu(struct mlx5_core_dev *dev, u16 mtu, u8 port); 1558c2ecf20Sopenharmony_civoid mlx5_query_port_max_mtu(struct mlx5_core_dev *dev, u16 *max_mtu, u8 port); 1568c2ecf20Sopenharmony_civoid mlx5_query_port_oper_mtu(struct mlx5_core_dev *dev, u16 *oper_mtu, 1578c2ecf20Sopenharmony_ci u8 port); 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_ciint mlx5_query_port_vl_hw_cap(struct mlx5_core_dev *dev, 1608c2ecf20Sopenharmony_ci u8 *vl_hw_cap, u8 local_port); 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ciint mlx5_set_port_pause(struct mlx5_core_dev *dev, u32 rx_pause, u32 tx_pause); 1638c2ecf20Sopenharmony_ciint mlx5_query_port_pause(struct mlx5_core_dev *dev, 1648c2ecf20Sopenharmony_ci u32 *rx_pause, u32 *tx_pause); 1658c2ecf20Sopenharmony_ci 1668c2ecf20Sopenharmony_ciint mlx5_set_port_pfc(struct mlx5_core_dev *dev, u8 pfc_en_tx, u8 pfc_en_rx); 1678c2ecf20Sopenharmony_ciint mlx5_query_port_pfc(struct mlx5_core_dev *dev, u8 *pfc_en_tx, 1688c2ecf20Sopenharmony_ci u8 *pfc_en_rx); 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ciint mlx5_set_port_stall_watermark(struct mlx5_core_dev *dev, 1718c2ecf20Sopenharmony_ci u16 stall_critical_watermark, 1728c2ecf20Sopenharmony_ci u16 stall_minor_watermark); 1738c2ecf20Sopenharmony_ciint mlx5_query_port_stall_watermark(struct mlx5_core_dev *dev, 1748c2ecf20Sopenharmony_ci u16 *stall_critical_watermark, u16 *stall_minor_watermark); 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_ciint mlx5_max_tc(struct mlx5_core_dev *mdev); 1778c2ecf20Sopenharmony_ci 1788c2ecf20Sopenharmony_ciint mlx5_set_port_prio_tc(struct mlx5_core_dev *mdev, u8 *prio_tc); 1798c2ecf20Sopenharmony_ciint mlx5_query_port_prio_tc(struct mlx5_core_dev *mdev, 1808c2ecf20Sopenharmony_ci u8 prio, u8 *tc); 1818c2ecf20Sopenharmony_ciint mlx5_set_port_tc_group(struct mlx5_core_dev *mdev, u8 *tc_group); 1828c2ecf20Sopenharmony_ciint mlx5_query_port_tc_group(struct mlx5_core_dev *mdev, 1838c2ecf20Sopenharmony_ci u8 tc, u8 *tc_group); 1848c2ecf20Sopenharmony_ciint mlx5_set_port_tc_bw_alloc(struct mlx5_core_dev *mdev, u8 *tc_bw); 1858c2ecf20Sopenharmony_ciint mlx5_query_port_tc_bw_alloc(struct mlx5_core_dev *mdev, 1868c2ecf20Sopenharmony_ci u8 tc, u8 *bw_pct); 1878c2ecf20Sopenharmony_ciint mlx5_modify_port_ets_rate_limit(struct mlx5_core_dev *mdev, 1888c2ecf20Sopenharmony_ci u8 *max_bw_value, 1898c2ecf20Sopenharmony_ci u8 *max_bw_unit); 1908c2ecf20Sopenharmony_ciint mlx5_query_port_ets_rate_limit(struct mlx5_core_dev *mdev, 1918c2ecf20Sopenharmony_ci u8 *max_bw_value, 1928c2ecf20Sopenharmony_ci u8 *max_bw_unit); 1938c2ecf20Sopenharmony_ciint mlx5_set_port_wol(struct mlx5_core_dev *mdev, u8 wol_mode); 1948c2ecf20Sopenharmony_ciint mlx5_query_port_wol(struct mlx5_core_dev *mdev, u8 *wol_mode); 1958c2ecf20Sopenharmony_ci 1968c2ecf20Sopenharmony_ciint mlx5_query_ports_check(struct mlx5_core_dev *mdev, u32 *out, int outlen); 1978c2ecf20Sopenharmony_ciint mlx5_set_ports_check(struct mlx5_core_dev *mdev, u32 *in, int inlen); 1988c2ecf20Sopenharmony_ciint mlx5_set_port_fcs(struct mlx5_core_dev *mdev, u8 enable); 1998c2ecf20Sopenharmony_civoid mlx5_query_port_fcs(struct mlx5_core_dev *mdev, bool *supported, 2008c2ecf20Sopenharmony_ci bool *enabled); 2018c2ecf20Sopenharmony_ciint mlx5_query_module_eeprom(struct mlx5_core_dev *dev, 2028c2ecf20Sopenharmony_ci u16 offset, u16 size, u8 *data); 2038c2ecf20Sopenharmony_ci 2048c2ecf20Sopenharmony_ciint mlx5_query_port_dcbx_param(struct mlx5_core_dev *mdev, u32 *out); 2058c2ecf20Sopenharmony_ciint mlx5_set_port_dcbx_param(struct mlx5_core_dev *mdev, u32 *in); 2068c2ecf20Sopenharmony_ci 2078c2ecf20Sopenharmony_ciint mlx5_set_trust_state(struct mlx5_core_dev *mdev, u8 trust_state); 2088c2ecf20Sopenharmony_ciint mlx5_query_trust_state(struct mlx5_core_dev *mdev, u8 *trust_state); 2098c2ecf20Sopenharmony_ciint mlx5_set_dscp2prio(struct mlx5_core_dev *mdev, u8 dscp, u8 prio); 2108c2ecf20Sopenharmony_ciint mlx5_query_dscp2prio(struct mlx5_core_dev *mdev, u8 *dscp2prio); 2118c2ecf20Sopenharmony_ci#endif /* __MLX5_PORT_H__ */ 212