1 /* 2 * Copyright (c) 2016 QLogic Corporation. 3 * All rights reserved. 4 * www.qlogic.com 5 * 6 * See LICENSE.qede_pmd for copyright and licensing details. 7 */ 8 9 #ifndef __ECORE_MCP_API_H__ 10 #define __ECORE_MCP_API_H__ 11 12 #include "ecore_status.h" 13 14 struct ecore_mcp_link_speed_params { 15 bool autoneg; 16 u32 advertised_speeds; /* bitmask of DRV_SPEED_CAPABILITY */ 17 u32 forced_speed; /* In Mb/s */ 18 }; 19 20 struct ecore_mcp_link_pause_params { 21 bool autoneg; 22 bool forced_rx; 23 bool forced_tx; 24 }; 25 26 struct ecore_mcp_link_params { 27 struct ecore_mcp_link_speed_params speed; 28 struct ecore_mcp_link_pause_params pause; 29 u32 loopback_mode; /* in PMM_LOOPBACK values */ 30 }; 31 32 struct ecore_mcp_link_capabilities { 33 u32 speed_capabilities; 34 }; 35 36 struct ecore_mcp_link_state { 37 bool link_up; 38 39 u32 line_speed; /* In Mb/s */ 40 u32 min_pf_rate; /* In Mb/s */ 41 u32 speed; /* In Mb/s */ 42 bool full_duplex; 43 44 bool an; 45 bool an_complete; 46 bool parallel_detection; 47 bool pfc_enabled; 48 49 #define ECORE_LINK_PARTNER_SPEED_1G_HD (1 << 0) 50 #define ECORE_LINK_PARTNER_SPEED_1G_FD (1 << 1) 51 #define ECORE_LINK_PARTNER_SPEED_10G (1 << 2) 52 #define ECORE_LINK_PARTNER_SPEED_20G (1 << 3) 53 #define ECORE_LINK_PARTNER_SPEED_25G (1 << 4) 54 #define ECORE_LINK_PARTNER_SPEED_40G (1 << 5) 55 #define ECORE_LINK_PARTNER_SPEED_50G (1 << 6) 56 #define ECORE_LINK_PARTNER_SPEED_100G (1 << 7) 57 u32 partner_adv_speed; 58 59 bool partner_tx_flow_ctrl_en; 60 bool partner_rx_flow_ctrl_en; 61 62 #define ECORE_LINK_PARTNER_SYMMETRIC_PAUSE (1) 63 #define ECORE_LINK_PARTNER_ASYMMETRIC_PAUSE (2) 64 #define ECORE_LINK_PARTNER_BOTH_PAUSE (3) 65 u8 partner_adv_pause; 66 67 bool sfp_tx_fault; 68 }; 69 70 struct ecore_mcp_function_info { 71 u8 pause_on_host; 72 73 enum ecore_pci_personality protocol; 74 75 u8 bandwidth_min; 76 u8 bandwidth_max; 77 78 u8 mac[ETH_ALEN]; 79 80 u64 wwn_port; 81 u64 wwn_node; 82 83 #define ECORE_MCP_VLAN_UNSET (0xffff) 84 u16 ovlan; 85 }; 86 87 struct ecore_mcp_nvm_common { 88 u32 offset; 89 u32 param; 90 u32 resp; 91 u32 cmd; 92 }; 93 94 struct ecore_mcp_nvm_rd { 95 u32 *buf_size; 96 u32 *buf; 97 }; 98 99 struct ecore_mcp_nvm_wr { 100 u32 buf_size; 101 u32 *buf; 102 }; 103 104 struct ecore_mcp_nvm_params { 105 #define ECORE_MCP_CMD (1 << 0) 106 #define ECORE_MCP_NVM_RD (1 << 1) 107 #define ECORE_MCP_NVM_WR (1 << 2) 108 u8 type; 109 110 struct ecore_mcp_nvm_common nvm_common; 111 112 union { 113 struct ecore_mcp_nvm_rd nvm_rd; 114 struct ecore_mcp_nvm_wr nvm_wr; 115 }; 116 }; 117 118 struct ecore_mcp_drv_version { 119 u32 version; 120 u8 name[MCP_DRV_VER_STR_SIZE - 4]; 121 }; 122 123 struct ecore_mcp_lan_stats { 124 u64 ucast_rx_pkts; 125 u64 ucast_tx_pkts; 126 u32 fcs_err; 127 }; 128 129 #ifndef ECORE_PROTO_STATS 130 #define ECORE_PROTO_STATS 131 132 enum ecore_mcp_protocol_type { 133 ECORE_MCP_LAN_STATS, 134 }; 135 136 union ecore_mcp_protocol_stats { 137 struct ecore_mcp_lan_stats lan_stats; 138 }; 139 #endif 140 141 enum ecore_ov_config_method { 142 ECORE_OV_CONFIG_MTU, 143 ECORE_OV_CONFIG_MAC, 144 ECORE_OV_CONFIG_WOL 145 }; 146 147 enum ecore_ov_client { 148 ECORE_OV_CLIENT_DRV, 149 ECORE_OV_CLIENT_USER 150 }; 151 152 enum ecore_ov_driver_state { 153 ECORE_OV_DRIVER_STATE_NOT_LOADED, 154 ECORE_OV_DRIVER_STATE_DISABLED, 155 ECORE_OV_DRIVER_STATE_ACTIVE 156 }; 157 158 #define ECORE_MAX_NPIV_ENTRIES 128 159 #define ECORE_WWN_SIZE 8 160 struct ecore_fc_npiv_tbl { 161 u32 count; 162 u8 wwpn[ECORE_MAX_NPIV_ENTRIES][ECORE_WWN_SIZE]; 163 u8 wwnn[ECORE_MAX_NPIV_ENTRIES][ECORE_WWN_SIZE]; 164 }; 165 166 #ifndef __EXTRACT__LINUX__ 167 enum ecore_led_mode { 168 ECORE_LED_MODE_OFF, 169 ECORE_LED_MODE_ON, 170 ECORE_LED_MODE_RESTORE 171 }; 172 #endif 173 174 /** 175 * @brief - returns the link params of the hw function 176 * 177 * @param p_hwfn 178 * 179 * @returns pointer to link params 180 */ 181 struct ecore_mcp_link_params *ecore_mcp_get_link_params(struct ecore_hwfn *); 182 183 /** 184 * @brief - return the link state of the hw function 185 * 186 * @param p_hwfn 187 * 188 * @returns pointer to link state 189 */ 190 struct ecore_mcp_link_state *ecore_mcp_get_link_state(struct ecore_hwfn *); 191 192 /** 193 * @brief - return the link capabilities of the hw function 194 * 195 * @param p_hwfn 196 * 197 * @returns pointer to link capabilities 198 */ 199 struct ecore_mcp_link_capabilities 200 *ecore_mcp_get_link_capabilities(struct ecore_hwfn *p_hwfn); 201 202 /** 203 * @brief Request the MFW to set the the link according to 'link_input'. 204 * 205 * @param p_hwfn 206 * @param p_ptt 207 * @param b_up - raise link if `true'. Reset link if `false'. 208 * 209 * @return enum _ecore_status_t 210 */ 211 enum _ecore_status_t ecore_mcp_set_link(struct ecore_hwfn *p_hwfn, 212 struct ecore_ptt *p_ptt, bool b_up); 213 214 /** 215 * @brief Get the management firmware version value 216 * 217 * @param p_dev - ecore dev pointer 218 * @param p_ptt 219 * @param p_mfw_ver - mfw version value 220 * @param p_running_bundle_id - image id in nvram; Optional. 221 * 222 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful. 223 */ 224 enum _ecore_status_t ecore_mcp_get_mfw_ver(struct ecore_dev *p_dev, 225 struct ecore_ptt *p_ptt, 226 u32 *p_mfw_ver, 227 u32 *p_running_bundle_id); 228 229 /** 230 * @brief Get media type value of the port. 231 * 232 * @param p_dev - ecore dev pointer 233 * @param mfw_ver - media type value 234 * 235 * @return enum _ecore_status_t - 236 * ECORE_SUCCESS - Operation was successful. 237 * ECORE_BUSY - Operation failed 238 */ 239 enum _ecore_status_t ecore_mcp_get_media_type(struct ecore_dev *p_dev, 240 u32 *media_type); 241 242 /** 243 * @brief - Sends a command to the MCP mailbox. 244 * 245 * @param p_hwfn - hw function 246 * @param p_ptt - PTT required for register access 247 * @param cmd - command to be sent to the MCP 248 * @param param - optional param 249 * @param o_mcp_resp - the MCP response code (exclude sequence) 250 * @param o_mcp_param - optional parameter provided by the MCP response 251 * 252 * @return enum _ecore_status_t - 253 * ECORE_SUCCESS - operation was successful 254 * ECORE_BUSY - operation failed 255 */ 256 enum _ecore_status_t ecore_mcp_cmd(struct ecore_hwfn *p_hwfn, 257 struct ecore_ptt *p_ptt, u32 cmd, u32 param, 258 u32 *o_mcp_resp, u32 *o_mcp_param); 259 260 /** 261 * @brief - drains the nig, allowing completion to pass in case of pauses. 262 * (Should be called only from sleepable context) 263 * 264 * @param p_hwfn 265 * @param p_ptt 266 */ 267 enum _ecore_status_t ecore_mcp_drain(struct ecore_hwfn *p_hwfn, 268 struct ecore_ptt *p_ptt); 269 270 /** 271 * @brief - return the mcp function info of the hw function 272 * 273 * @param p_hwfn 274 * 275 * @returns pointer to mcp function info 276 */ 277 const struct ecore_mcp_function_info 278 *ecore_mcp_get_function_info(struct ecore_hwfn *p_hwfn); 279 280 /** 281 * @brief - Function for reading/manipulating the nvram. Following are supported 282 * functionalities. 283 * 1. Read: Read the specified nvram offset. 284 * input values: 285 * type - ECORE_MCP_NVM_RD 286 * cmd - command code (e.g. DRV_MSG_CODE_NVM_READ_NVRAM) 287 * offset - nvm offset 288 * 289 * output values: 290 * buf - buffer 291 * buf_size - buffer size 292 * 293 * 2. Write: Write the data at the specified nvram offset 294 * input values: 295 * type - ECORE_MCP_NVM_WR 296 * cmd - command code (e.g. DRV_MSG_CODE_NVM_WRITE_NVRAM) 297 * offset - nvm offset 298 * buf - buffer 299 * buf_size - buffer size 300 * 301 * 3. Command: Send the NVM command to MCP. 302 * input values: 303 * type - ECORE_MCP_CMD 304 * cmd - command code (e.g. DRV_MSG_CODE_NVM_DEL_FILE) 305 * offset - nvm offset 306 * 307 * 308 * @param p_hwfn 309 * @param p_ptt 310 * @param params 311 * 312 * @return ECORE_SUCCESS - operation was successful. 313 */ 314 enum _ecore_status_t ecore_mcp_nvm_command(struct ecore_hwfn *p_hwfn, 315 struct ecore_ptt *p_ptt, 316 struct ecore_mcp_nvm_params *params); 317 318 /** 319 * @brief - count number of function with a matching personality on engine. 320 * 321 * @param p_hwfn 322 * @param p_ptt 323 * @param personalities - a bitmask of ecore_pci_personality values 324 * 325 * @returns the count of all devices on engine whose personality match one of 326 * the bitsmasks. 327 */ 328 int ecore_mcp_get_personality_cnt(struct ecore_hwfn *p_hwfn, 329 struct ecore_ptt *p_ptt, u32 personalities); 330 331 /** 332 * @brief Get the flash size value 333 * 334 * @param p_hwfn 335 * @param p_ptt 336 * @param p_flash_size - flash size in bytes to be filled. 337 * 338 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful. 339 */ 340 enum _ecore_status_t ecore_mcp_get_flash_size(struct ecore_hwfn *p_hwfn, 341 struct ecore_ptt *p_ptt, 342 u32 *p_flash_size); 343 344 /** 345 * @brief Send driver version to MFW 346 * 347 * @param p_hwfn 348 * @param p_ptt 349 * @param version - Version value 350 * @param name - Protocol driver name 351 * 352 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful. 353 */ 354 enum _ecore_status_t 355 ecore_mcp_send_drv_version(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt, 356 struct ecore_mcp_drv_version *p_ver); 357 358 /** 359 * @brief Read the MFW process kill counter 360 * 361 * @param p_hwfn 362 * @param p_ptt 363 * 364 * @return u32 365 */ 366 u32 ecore_get_process_kill_counter(struct ecore_hwfn *p_hwfn, 367 struct ecore_ptt *p_ptt); 368 369 /** 370 * @brief Trigger a recovery process 371 * 372 * @param p_hwfn 373 * @param p_ptt 374 * 375 * @return enum _ecore_status_t 376 */ 377 enum _ecore_status_t ecore_start_recovery_process(struct ecore_hwfn *p_hwfn, 378 struct ecore_ptt *p_ptt); 379 380 /** 381 * @brief Notify MFW about the change in base device properties 382 * 383 * @param p_hwfn 384 * @param p_ptt 385 * @param config - Configuation that has been updated 386 * @param client - ecore client type 387 * 388 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful. 389 */ 390 enum _ecore_status_t 391 ecore_mcp_ov_update_current_config(struct ecore_hwfn *p_hwfn, 392 struct ecore_ptt *p_ptt, 393 enum ecore_ov_config_method config, 394 enum ecore_ov_client client); 395 396 /** 397 * @brief Notify MFW about the driver state 398 * 399 * @param p_hwfn 400 * @param p_ptt 401 * @param drv_state - Driver state 402 * 403 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful. 404 */ 405 enum _ecore_status_t 406 ecore_mcp_ov_update_driver_state(struct ecore_hwfn *p_hwfn, 407 struct ecore_ptt *p_ptt, 408 enum ecore_ov_driver_state drv_state); 409 410 /** 411 * @brief Read NPIV settings form the MFW 412 * 413 * @param p_hwfn 414 * @param p_ptt 415 * @param p_table - Array to hold the FC NPIV data. Client need allocate the 416 * required buffer. The field 'count' specifies number of NPIV 417 * entries. A value of 0 means the table was not populated. 418 * 419 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful. 420 */ 421 enum _ecore_status_t 422 ecore_mcp_ov_get_fc_npiv(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt, 423 struct ecore_fc_npiv_tbl *p_table); 424 425 /** 426 * @brief Send MTU size to MFW 427 * 428 * @param p_hwfn 429 * @param p_ptt 430 * @param mtu - MTU size 431 * 432 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful. 433 */ 434 enum _ecore_status_t ecore_mcp_ov_update_mtu(struct ecore_hwfn *p_hwfn, 435 struct ecore_ptt *p_ptt, u16 mtu); 436 437 /** 438 * @brief Set LED status 439 * 440 * @param p_hwfn 441 * @param p_ptt 442 * @param mode - LED mode 443 * 444 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful. 445 */ 446 enum _ecore_status_t ecore_mcp_set_led(struct ecore_hwfn *p_hwfn, 447 struct ecore_ptt *p_ptt, 448 enum ecore_led_mode mode); 449 450 /** 451 * @brief Set secure mode 452 * 453 * @param p_dev 454 * @param addr - nvm offset 455 * 456 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful. 457 */ 458 enum _ecore_status_t ecore_mcp_nvm_set_secure_mode(struct ecore_dev *p_dev, 459 u32 addr); 460 461 /** 462 * @brief Write to phy 463 * 464 * @param p_dev 465 * @param addr - nvm offset 466 * @param cmd - nvm command 467 * @param p_buf - nvm write buffer 468 * @param len - buffer len 469 * 470 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful. 471 */ 472 enum _ecore_status_t ecore_mcp_phy_write(struct ecore_dev *p_dev, u32 cmd, 473 u32 addr, u8 *p_buf, u32 len); 474 475 /** 476 * @brief Write to nvm 477 * 478 * @param p_dev 479 * @param addr - nvm offset 480 * @param cmd - nvm command 481 * @param p_buf - nvm write buffer 482 * @param len - buffer len 483 * 484 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful. 485 */ 486 enum _ecore_status_t ecore_mcp_nvm_write(struct ecore_dev *p_dev, u32 cmd, 487 u32 addr, u8 *p_buf, u32 len); 488 489 /** 490 * @brief Put file begin 491 * 492 * @param p_dev 493 * @param addr - nvm offset 494 * 495 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful. 496 */ 497 enum _ecore_status_t ecore_mcp_nvm_put_file_begin(struct ecore_dev *p_dev, 498 u32 addr); 499 500 /** 501 * @brief Delete file 502 * 503 * @param p_dev 504 * @param addr - nvm offset 505 * 506 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful. 507 */ 508 enum _ecore_status_t ecore_mcp_nvm_del_file(struct ecore_dev *p_dev, u32 addr); 509 510 /** 511 * @brief Check latest response 512 * 513 * @param p_dev 514 * @param p_buf - nvm write buffer 515 * 516 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful. 517 */ 518 enum _ecore_status_t ecore_mcp_nvm_resp(struct ecore_dev *p_dev, u8 *p_buf); 519 520 /** 521 * @brief Read from phy 522 * 523 * @param p_dev 524 * @param addr - nvm offset 525 * @param cmd - nvm command 526 * @param p_buf - nvm write buffer 527 * @param len - buffer len 528 * 529 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful. 530 */ 531 enum _ecore_status_t ecore_mcp_phy_read(struct ecore_dev *p_dev, u32 cmd, 532 u32 addr, u8 *p_buf, u32 len); 533 534 /** 535 * @brief Read from nvm 536 * 537 * @param p_dev 538 * @param addr - nvm offset 539 * @param p_buf - nvm write buffer 540 * @param len - buffer len 541 * 542 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful. 543 */ 544 enum _ecore_status_t ecore_mcp_nvm_read(struct ecore_dev *p_dev, u32 addr, 545 u8 *p_buf, u32 len); 546 547 /** 548 * @brief Read from sfp 549 * 550 * @param p_hwfn - hw function 551 * @param p_ptt - PTT required for register access 552 * @param port - transceiver port 553 * @param addr - I2C address 554 * @param offset - offset in sfp 555 * @param len - buffer length 556 * @param p_buf - buffer to read into 557 * 558 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful. 559 */ 560 enum _ecore_status_t ecore_mcp_phy_sfp_read(struct ecore_hwfn *p_hwfn, 561 struct ecore_ptt *p_ptt, 562 u32 port, u32 addr, u32 offset, 563 u32 len, u8 *p_buf); 564 565 /** 566 * @brief Write to sfp 567 * 568 * @param p_hwfn - hw function 569 * @param p_ptt - PTT required for register access 570 * @param port - transceiver port 571 * @param addr - I2C address 572 * @param offset - offset in sfp 573 * @param len - buffer length 574 * @param p_buf - buffer to write from 575 * 576 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful. 577 */ 578 enum _ecore_status_t ecore_mcp_phy_sfp_write(struct ecore_hwfn *p_hwfn, 579 struct ecore_ptt *p_ptt, 580 u32 port, u32 addr, u32 offset, 581 u32 len, u8 *p_buf); 582 583 /** 584 * @brief Gpio read 585 * 586 * @param p_hwfn - hw function 587 * @param p_ptt - PTT required for register access 588 * @param gpio - gpio number 589 * @param gpio_val - value read from gpio 590 * 591 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful. 592 */ 593 enum _ecore_status_t ecore_mcp_gpio_read(struct ecore_hwfn *p_hwfn, 594 struct ecore_ptt *p_ptt, 595 u16 gpio, u32 *gpio_val); 596 597 /** 598 * @brief Gpio write 599 * 600 * @param p_hwfn - hw function 601 * @param p_ptt - PTT required for register access 602 * @param gpio - gpio number 603 * @param gpio_val - value to write to gpio 604 * 605 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful. 606 */ 607 enum _ecore_status_t ecore_mcp_gpio_write(struct ecore_hwfn *p_hwfn, 608 struct ecore_ptt *p_ptt, 609 u16 gpio, u16 gpio_val); 610 611 #endif 612