switchib.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
  2. /* Copyright (c) 2016-2018 Mellanox Technologies. All rights reserved */
  3. #include <linux/kernel.h>
  4. #include <linux/module.h>
  5. #include <linux/types.h>
  6. #include <linux/pci.h>
  7. #include <linux/netdevice.h>
  8. #include <linux/etherdevice.h>
  9. #include <linux/slab.h>
  10. #include <linux/device.h>
  11. #include <linux/skbuff.h>
  12. #include <linux/if_vlan.h>
  13. #include <net/switchdev.h>
  14. #include "pci.h"
  15. #include "core.h"
  16. #include "reg.h"
  17. #include "port.h"
  18. #include "trap.h"
  19. #include "txheader.h"
  20. #include "ib.h"
  21. static const char mlxsw_sib_driver_name[] = "mlxsw_switchib";
  22. static const char mlxsw_sib2_driver_name[] = "mlxsw_switchib2";
  23. struct mlxsw_sib_port;
  24. struct mlxsw_sib {
  25. struct mlxsw_sib_port **ports;
  26. struct mlxsw_core *core;
  27. const struct mlxsw_bus_info *bus_info;
  28. };
  29. struct mlxsw_sib_port {
  30. struct mlxsw_sib *mlxsw_sib;
  31. u8 local_port;
  32. struct {
  33. u8 module;
  34. } mapping;
  35. };
  36. /* tx_v1_hdr_version
  37. * Tx header version.
  38. * Must be set to 1.
  39. */
  40. MLXSW_ITEM32(tx_v1, hdr, version, 0x00, 28, 4);
  41. /* tx_v1_hdr_ctl
  42. * Packet control type.
  43. * 0 - Ethernet control (e.g. EMADs, LACP)
  44. * 1 - Ethernet data
  45. */
  46. MLXSW_ITEM32(tx_v1, hdr, ctl, 0x00, 26, 2);
  47. /* tx_v1_hdr_proto
  48. * Packet protocol type. Must be set to 1 (Ethernet).
  49. */
  50. MLXSW_ITEM32(tx_v1, hdr, proto, 0x00, 21, 3);
  51. /* tx_v1_hdr_swid
  52. * Switch partition ID. Must be set to 0.
  53. */
  54. MLXSW_ITEM32(tx_v1, hdr, swid, 0x00, 12, 3);
  55. /* tx_v1_hdr_control_tclass
  56. * Indicates if the packet should use the control TClass and not one
  57. * of the data TClasses.
  58. */
  59. MLXSW_ITEM32(tx_v1, hdr, control_tclass, 0x00, 6, 1);
  60. /* tx_v1_hdr_port_mid
  61. * Destination local port for unicast packets.
  62. * Destination multicast ID for multicast packets.
  63. *
  64. * Control packets are directed to a specific egress port, while data
  65. * packets are transmitted through the CPU port (0) into the switch partition,
  66. * where forwarding rules are applied.
  67. */
  68. MLXSW_ITEM32(tx_v1, hdr, port_mid, 0x04, 16, 16);
  69. /* tx_v1_hdr_type
  70. * 0 - Data packets
  71. * 6 - Control packets
  72. */
  73. MLXSW_ITEM32(tx_v1, hdr, type, 0x0C, 0, 4);
  74. static void
  75. mlxsw_sib_tx_v1_hdr_construct(struct sk_buff *skb,
  76. const struct mlxsw_tx_info *tx_info)
  77. {
  78. char *txhdr = skb_push(skb, MLXSW_TXHDR_LEN);
  79. memset(txhdr, 0, MLXSW_TXHDR_LEN);
  80. mlxsw_tx_v1_hdr_version_set(txhdr, MLXSW_TXHDR_VERSION_1);
  81. mlxsw_tx_v1_hdr_ctl_set(txhdr, MLXSW_TXHDR_ETH_CTL);
  82. mlxsw_tx_v1_hdr_proto_set(txhdr, MLXSW_TXHDR_PROTO_ETH);
  83. mlxsw_tx_v1_hdr_swid_set(txhdr, 0);
  84. mlxsw_tx_v1_hdr_control_tclass_set(txhdr, 1);
  85. mlxsw_tx_v1_hdr_port_mid_set(txhdr, tx_info->local_port);
  86. mlxsw_tx_v1_hdr_type_set(txhdr, MLXSW_TXHDR_TYPE_CONTROL);
  87. }
  88. static int
  89. mlxsw_sib_port_admin_status_set(struct mlxsw_sib_port *mlxsw_sib_port,
  90. bool is_up)
  91. {
  92. struct mlxsw_sib *mlxsw_sib = mlxsw_sib_port->mlxsw_sib;
  93. char paos_pl[MLXSW_REG_PAOS_LEN];
  94. mlxsw_reg_paos_pack(paos_pl, mlxsw_sib_port->local_port,
  95. is_up ? MLXSW_PORT_ADMIN_STATUS_UP :
  96. MLXSW_PORT_ADMIN_STATUS_DOWN);
  97. return mlxsw_reg_write(mlxsw_sib->core, MLXSW_REG(paos), paos_pl);
  98. }
  99. static int mlxsw_sib_port_mtu_set(struct mlxsw_sib_port *mlxsw_sib_port,
  100. u16 mtu)
  101. {
  102. struct mlxsw_sib *mlxsw_sib = mlxsw_sib_port->mlxsw_sib;
  103. char pmtu_pl[MLXSW_REG_PMTU_LEN];
  104. int max_mtu;
  105. int err;
  106. mlxsw_reg_pmtu_pack(pmtu_pl, mlxsw_sib_port->local_port, 0);
  107. err = mlxsw_reg_query(mlxsw_sib->core, MLXSW_REG(pmtu), pmtu_pl);
  108. if (err)
  109. return err;
  110. max_mtu = mlxsw_reg_pmtu_max_mtu_get(pmtu_pl);
  111. if (mtu > max_mtu)
  112. return -EINVAL;
  113. mlxsw_reg_pmtu_pack(pmtu_pl, mlxsw_sib_port->local_port, mtu);
  114. return mlxsw_reg_write(mlxsw_sib->core, MLXSW_REG(pmtu), pmtu_pl);
  115. }
  116. static int mlxsw_sib_port_set(struct mlxsw_sib_port *mlxsw_sib_port, u8 port)
  117. {
  118. struct mlxsw_sib *mlxsw_sib = mlxsw_sib_port->mlxsw_sib;
  119. char plib_pl[MLXSW_REG_PLIB_LEN] = {0};
  120. int err;
  121. mlxsw_reg_plib_local_port_set(plib_pl, mlxsw_sib_port->local_port);
  122. mlxsw_reg_plib_ib_port_set(plib_pl, port);
  123. err = mlxsw_reg_write(mlxsw_sib->core, MLXSW_REG(plib), plib_pl);
  124. return err;
  125. }
  126. static int mlxsw_sib_port_swid_set(struct mlxsw_sib_port *mlxsw_sib_port,
  127. u8 swid)
  128. {
  129. struct mlxsw_sib *mlxsw_sib = mlxsw_sib_port->mlxsw_sib;
  130. char pspa_pl[MLXSW_REG_PSPA_LEN];
  131. mlxsw_reg_pspa_pack(pspa_pl, swid, mlxsw_sib_port->local_port);
  132. return mlxsw_reg_write(mlxsw_sib->core, MLXSW_REG(pspa), pspa_pl);
  133. }
  134. static int mlxsw_sib_port_module_info_get(struct mlxsw_sib *mlxsw_sib,
  135. u8 local_port, u8 *p_module,
  136. u8 *p_width)
  137. {
  138. char pmlp_pl[MLXSW_REG_PMLP_LEN];
  139. int err;
  140. mlxsw_reg_pmlp_pack(pmlp_pl, local_port);
  141. err = mlxsw_reg_query(mlxsw_sib->core, MLXSW_REG(pmlp), pmlp_pl);
  142. if (err)
  143. return err;
  144. *p_module = mlxsw_reg_pmlp_module_get(pmlp_pl, 0);
  145. *p_width = mlxsw_reg_pmlp_width_get(pmlp_pl);
  146. return 0;
  147. }
  148. static int mlxsw_sib_port_speed_set(struct mlxsw_sib_port *mlxsw_sib_port,
  149. u16 speed, u16 width)
  150. {
  151. struct mlxsw_sib *mlxsw_sib = mlxsw_sib_port->mlxsw_sib;
  152. char ptys_pl[MLXSW_REG_PTYS_LEN];
  153. mlxsw_reg_ptys_ib_pack(ptys_pl, mlxsw_sib_port->local_port, speed,
  154. width);
  155. return mlxsw_reg_write(mlxsw_sib->core, MLXSW_REG(ptys), ptys_pl);
  156. }
  157. static bool mlxsw_sib_port_created(struct mlxsw_sib *mlxsw_sib, u8 local_port)
  158. {
  159. return mlxsw_sib->ports[local_port] != NULL;
  160. }
  161. static int __mlxsw_sib_port_create(struct mlxsw_sib *mlxsw_sib, u8 local_port,
  162. u8 module, u8 width)
  163. {
  164. struct mlxsw_sib_port *mlxsw_sib_port;
  165. int err;
  166. mlxsw_sib_port = kzalloc(sizeof(*mlxsw_sib_port), GFP_KERNEL);
  167. if (!mlxsw_sib_port)
  168. return -ENOMEM;
  169. mlxsw_sib_port->mlxsw_sib = mlxsw_sib;
  170. mlxsw_sib_port->local_port = local_port;
  171. mlxsw_sib_port->mapping.module = module;
  172. err = mlxsw_sib_port_swid_set(mlxsw_sib_port, 0);
  173. if (err) {
  174. dev_err(mlxsw_sib->bus_info->dev, "Port %d: Failed to set SWID\n",
  175. mlxsw_sib_port->local_port);
  176. goto err_port_swid_set;
  177. }
  178. /* Expose the IB port number as it's front panel name */
  179. err = mlxsw_sib_port_set(mlxsw_sib_port, module + 1);
  180. if (err) {
  181. dev_err(mlxsw_sib->bus_info->dev, "Port %d: Failed to set IB port\n",
  182. mlxsw_sib_port->local_port);
  183. goto err_port_ib_set;
  184. }
  185. /* Supports all speeds from SDR to FDR (bitmask) and support bus width
  186. * of 1x, 2x and 4x (3 bits bitmask)
  187. */
  188. err = mlxsw_sib_port_speed_set(mlxsw_sib_port,
  189. MLXSW_REG_PTYS_IB_SPEED_EDR - 1,
  190. BIT(3) - 1);
  191. if (err) {
  192. dev_err(mlxsw_sib->bus_info->dev, "Port %d: Failed to set speed\n",
  193. mlxsw_sib_port->local_port);
  194. goto err_port_speed_set;
  195. }
  196. /* Change to the maximum MTU the device supports, the SMA will take
  197. * care of the active MTU
  198. */
  199. err = mlxsw_sib_port_mtu_set(mlxsw_sib_port, MLXSW_IB_DEFAULT_MTU);
  200. if (err) {
  201. dev_err(mlxsw_sib->bus_info->dev, "Port %d: Failed to set MTU\n",
  202. mlxsw_sib_port->local_port);
  203. goto err_port_mtu_set;
  204. }
  205. err = mlxsw_sib_port_admin_status_set(mlxsw_sib_port, true);
  206. if (err) {
  207. dev_err(mlxsw_sib->bus_info->dev, "Port %d: Failed to change admin state to UP\n",
  208. mlxsw_sib_port->local_port);
  209. goto err_port_admin_set;
  210. }
  211. mlxsw_core_port_ib_set(mlxsw_sib->core, mlxsw_sib_port->local_port,
  212. mlxsw_sib_port);
  213. mlxsw_sib->ports[local_port] = mlxsw_sib_port;
  214. return 0;
  215. err_port_admin_set:
  216. err_port_mtu_set:
  217. err_port_speed_set:
  218. err_port_ib_set:
  219. mlxsw_sib_port_swid_set(mlxsw_sib_port, MLXSW_PORT_SWID_DISABLED_PORT);
  220. err_port_swid_set:
  221. kfree(mlxsw_sib_port);
  222. return err;
  223. }
  224. static int mlxsw_sib_port_create(struct mlxsw_sib *mlxsw_sib, u8 local_port,
  225. u8 module, u8 width)
  226. {
  227. int err;
  228. err = mlxsw_core_port_init(mlxsw_sib->core, local_port);
  229. if (err) {
  230. dev_err(mlxsw_sib->bus_info->dev, "Port %d: Failed to init core port\n",
  231. local_port);
  232. return err;
  233. }
  234. err = __mlxsw_sib_port_create(mlxsw_sib, local_port, module, width);
  235. if (err)
  236. goto err_port_create;
  237. return 0;
  238. err_port_create:
  239. mlxsw_core_port_fini(mlxsw_sib->core, local_port);
  240. return err;
  241. }
  242. static void __mlxsw_sib_port_remove(struct mlxsw_sib *mlxsw_sib, u8 local_port)
  243. {
  244. struct mlxsw_sib_port *mlxsw_sib_port = mlxsw_sib->ports[local_port];
  245. mlxsw_core_port_clear(mlxsw_sib->core, local_port, mlxsw_sib);
  246. mlxsw_sib->ports[local_port] = NULL;
  247. mlxsw_sib_port_admin_status_set(mlxsw_sib_port, false);
  248. mlxsw_sib_port_swid_set(mlxsw_sib_port, MLXSW_PORT_SWID_DISABLED_PORT);
  249. kfree(mlxsw_sib_port);
  250. }
  251. static void mlxsw_sib_port_remove(struct mlxsw_sib *mlxsw_sib, u8 local_port)
  252. {
  253. __mlxsw_sib_port_remove(mlxsw_sib, local_port);
  254. mlxsw_core_port_fini(mlxsw_sib->core, local_port);
  255. }
  256. static void mlxsw_sib_ports_remove(struct mlxsw_sib *mlxsw_sib)
  257. {
  258. int i;
  259. for (i = 1; i < MLXSW_PORT_MAX_IB_PORTS; i++)
  260. if (mlxsw_sib_port_created(mlxsw_sib, i))
  261. mlxsw_sib_port_remove(mlxsw_sib, i);
  262. kfree(mlxsw_sib->ports);
  263. }
  264. static int mlxsw_sib_ports_create(struct mlxsw_sib *mlxsw_sib)
  265. {
  266. size_t alloc_size;
  267. u8 module, width;
  268. int i;
  269. int err;
  270. alloc_size = sizeof(struct mlxsw_sib_port *) * MLXSW_PORT_MAX_IB_PORTS;
  271. mlxsw_sib->ports = kzalloc(alloc_size, GFP_KERNEL);
  272. if (!mlxsw_sib->ports)
  273. return -ENOMEM;
  274. for (i = 1; i < MLXSW_PORT_MAX_IB_PORTS; i++) {
  275. err = mlxsw_sib_port_module_info_get(mlxsw_sib, i, &module,
  276. &width);
  277. if (err)
  278. goto err_port_module_info_get;
  279. if (!width)
  280. continue;
  281. err = mlxsw_sib_port_create(mlxsw_sib, i, module, width);
  282. if (err)
  283. goto err_port_create;
  284. }
  285. return 0;
  286. err_port_create:
  287. err_port_module_info_get:
  288. for (i--; i >= 1; i--)
  289. if (mlxsw_sib_port_created(mlxsw_sib, i))
  290. mlxsw_sib_port_remove(mlxsw_sib, i);
  291. kfree(mlxsw_sib->ports);
  292. return err;
  293. }
  294. static void
  295. mlxsw_sib_pude_ib_event_func(struct mlxsw_sib_port *mlxsw_sib_port,
  296. enum mlxsw_reg_pude_oper_status status)
  297. {
  298. if (status == MLXSW_PORT_OPER_STATUS_UP)
  299. pr_info("ib link for port %d - up\n",
  300. mlxsw_sib_port->mapping.module + 1);
  301. else
  302. pr_info("ib link for port %d - down\n",
  303. mlxsw_sib_port->mapping.module + 1);
  304. }
  305. static void mlxsw_sib_pude_event_func(const struct mlxsw_reg_info *reg,
  306. char *pude_pl, void *priv)
  307. {
  308. struct mlxsw_sib *mlxsw_sib = priv;
  309. struct mlxsw_sib_port *mlxsw_sib_port;
  310. enum mlxsw_reg_pude_oper_status status;
  311. u8 local_port;
  312. local_port = mlxsw_reg_pude_local_port_get(pude_pl);
  313. mlxsw_sib_port = mlxsw_sib->ports[local_port];
  314. if (!mlxsw_sib_port) {
  315. dev_warn(mlxsw_sib->bus_info->dev, "Port %d: Link event received for non-existent port\n",
  316. local_port);
  317. return;
  318. }
  319. status = mlxsw_reg_pude_oper_status_get(pude_pl);
  320. mlxsw_sib_pude_ib_event_func(mlxsw_sib_port, status);
  321. }
  322. static const struct mlxsw_listener mlxsw_sib_listener[] = {
  323. MLXSW_EVENTL(mlxsw_sib_pude_event_func, PUDE, EMAD),
  324. };
  325. static int mlxsw_sib_taps_init(struct mlxsw_sib *mlxsw_sib)
  326. {
  327. int i;
  328. int err;
  329. for (i = 0; i < ARRAY_SIZE(mlxsw_sib_listener); i++) {
  330. err = mlxsw_core_trap_register(mlxsw_sib->core,
  331. &mlxsw_sib_listener[i],
  332. mlxsw_sib);
  333. if (err)
  334. goto err_rx_listener_register;
  335. }
  336. return 0;
  337. err_rx_listener_register:
  338. for (i--; i >= 0; i--) {
  339. mlxsw_core_trap_unregister(mlxsw_sib->core,
  340. &mlxsw_sib_listener[i],
  341. mlxsw_sib);
  342. }
  343. return err;
  344. }
  345. static void mlxsw_sib_traps_fini(struct mlxsw_sib *mlxsw_sib)
  346. {
  347. int i;
  348. for (i = 0; i < ARRAY_SIZE(mlxsw_sib_listener); i++) {
  349. mlxsw_core_trap_unregister(mlxsw_sib->core,
  350. &mlxsw_sib_listener[i], mlxsw_sib);
  351. }
  352. }
  353. static int mlxsw_sib_basic_trap_groups_set(struct mlxsw_core *mlxsw_core)
  354. {
  355. char htgt_pl[MLXSW_REG_HTGT_LEN];
  356. mlxsw_reg_htgt_pack(htgt_pl, MLXSW_REG_HTGT_TRAP_GROUP_EMAD,
  357. MLXSW_REG_HTGT_INVALID_POLICER,
  358. MLXSW_REG_HTGT_DEFAULT_PRIORITY,
  359. MLXSW_REG_HTGT_DEFAULT_TC);
  360. mlxsw_reg_htgt_swid_set(htgt_pl, MLXSW_PORT_SWID_ALL_SWIDS);
  361. mlxsw_reg_htgt_local_path_rdq_set(htgt_pl,
  362. MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SIB_EMAD);
  363. return mlxsw_reg_write(mlxsw_core, MLXSW_REG(htgt), htgt_pl);
  364. }
  365. static int mlxsw_sib_init(struct mlxsw_core *mlxsw_core,
  366. const struct mlxsw_bus_info *mlxsw_bus_info)
  367. {
  368. struct mlxsw_sib *mlxsw_sib = mlxsw_core_driver_priv(mlxsw_core);
  369. int err;
  370. mlxsw_sib->core = mlxsw_core;
  371. mlxsw_sib->bus_info = mlxsw_bus_info;
  372. err = mlxsw_sib_ports_create(mlxsw_sib);
  373. if (err) {
  374. dev_err(mlxsw_sib->bus_info->dev, "Failed to create ports\n");
  375. return err;
  376. }
  377. err = mlxsw_sib_taps_init(mlxsw_sib);
  378. if (err) {
  379. dev_err(mlxsw_sib->bus_info->dev, "Failed to set traps\n");
  380. goto err_traps_init_err;
  381. }
  382. return 0;
  383. err_traps_init_err:
  384. mlxsw_sib_ports_remove(mlxsw_sib);
  385. return err;
  386. }
  387. static void mlxsw_sib_fini(struct mlxsw_core *mlxsw_core)
  388. {
  389. struct mlxsw_sib *mlxsw_sib = mlxsw_core_driver_priv(mlxsw_core);
  390. mlxsw_sib_traps_fini(mlxsw_sib);
  391. mlxsw_sib_ports_remove(mlxsw_sib);
  392. }
  393. static const struct mlxsw_config_profile mlxsw_sib_config_profile = {
  394. .used_max_system_port = 1,
  395. .max_system_port = 48000,
  396. .used_max_ib_mc = 1,
  397. .max_ib_mc = 27,
  398. .used_max_pkey = 1,
  399. .max_pkey = 32,
  400. .swid_config = {
  401. {
  402. .used_type = 1,
  403. .type = MLXSW_PORT_SWID_TYPE_IB,
  404. }
  405. },
  406. };
  407. static struct mlxsw_driver mlxsw_sib_driver = {
  408. .kind = mlxsw_sib_driver_name,
  409. .priv_size = sizeof(struct mlxsw_sib),
  410. .init = mlxsw_sib_init,
  411. .fini = mlxsw_sib_fini,
  412. .basic_trap_groups_set = mlxsw_sib_basic_trap_groups_set,
  413. .txhdr_construct = mlxsw_sib_tx_v1_hdr_construct,
  414. .txhdr_len = MLXSW_TXHDR_LEN,
  415. .profile = &mlxsw_sib_config_profile,
  416. };
  417. static struct mlxsw_driver mlxsw_sib2_driver = {
  418. .kind = mlxsw_sib2_driver_name,
  419. .priv_size = sizeof(struct mlxsw_sib),
  420. .init = mlxsw_sib_init,
  421. .fini = mlxsw_sib_fini,
  422. .basic_trap_groups_set = mlxsw_sib_basic_trap_groups_set,
  423. .txhdr_construct = mlxsw_sib_tx_v1_hdr_construct,
  424. .txhdr_len = MLXSW_TXHDR_LEN,
  425. .profile = &mlxsw_sib_config_profile,
  426. };
  427. static const struct pci_device_id mlxsw_sib_pci_id_table[] = {
  428. {PCI_VDEVICE(MELLANOX, PCI_DEVICE_ID_MELLANOX_SWITCHIB), 0},
  429. {0, },
  430. };
  431. static struct pci_driver mlxsw_sib_pci_driver = {
  432. .name = mlxsw_sib_driver_name,
  433. .id_table = mlxsw_sib_pci_id_table,
  434. };
  435. static const struct pci_device_id mlxsw_sib2_pci_id_table[] = {
  436. {PCI_VDEVICE(MELLANOX, PCI_DEVICE_ID_MELLANOX_SWITCHIB2), 0},
  437. {0, },
  438. };
  439. static struct pci_driver mlxsw_sib2_pci_driver = {
  440. .name = mlxsw_sib2_driver_name,
  441. .id_table = mlxsw_sib2_pci_id_table,
  442. };
  443. static int __init mlxsw_sib_module_init(void)
  444. {
  445. int err;
  446. err = mlxsw_core_driver_register(&mlxsw_sib_driver);
  447. if (err)
  448. return err;
  449. err = mlxsw_core_driver_register(&mlxsw_sib2_driver);
  450. if (err)
  451. goto err_sib2_driver_register;
  452. err = mlxsw_pci_driver_register(&mlxsw_sib_pci_driver);
  453. if (err)
  454. goto err_sib_pci_driver_register;
  455. err = mlxsw_pci_driver_register(&mlxsw_sib2_pci_driver);
  456. if (err)
  457. goto err_sib2_pci_driver_register;
  458. return 0;
  459. err_sib2_pci_driver_register:
  460. mlxsw_pci_driver_unregister(&mlxsw_sib_pci_driver);
  461. err_sib_pci_driver_register:
  462. mlxsw_core_driver_unregister(&mlxsw_sib2_driver);
  463. err_sib2_driver_register:
  464. mlxsw_core_driver_unregister(&mlxsw_sib_driver);
  465. return err;
  466. }
  467. static void __exit mlxsw_sib_module_exit(void)
  468. {
  469. mlxsw_pci_driver_unregister(&mlxsw_sib2_pci_driver);
  470. mlxsw_pci_driver_unregister(&mlxsw_sib_pci_driver);
  471. mlxsw_core_driver_unregister(&mlxsw_sib2_driver);
  472. mlxsw_core_driver_unregister(&mlxsw_sib_driver);
  473. }
  474. module_init(mlxsw_sib_module_init);
  475. module_exit(mlxsw_sib_module_exit);
  476. MODULE_LICENSE("Dual BSD/GPL");
  477. MODULE_AUTHOR("Elad Raz <eladr@@mellanox.com>");
  478. MODULE_DESCRIPTION("Mellanox SwitchIB and SwitchIB-2 driver");
  479. MODULE_ALIAS("mlxsw_switchib2");
  480. MODULE_DEVICE_TABLE(pci, mlxsw_sib_pci_id_table);
  481. MODULE_DEVICE_TABLE(pci, mlxsw_sib2_pci_id_table);