| 418 | } |
| 419 | |
| 420 | int |
| 421 | sfc_mae_assign_switch_port(uint16_t switch_domain_id, |
| 422 | const struct sfc_mae_switch_port_request *req, |
| 423 | uint16_t *switch_port_id) |
| 424 | { |
| 425 | struct sfc_mae_switch_domain *domain; |
| 426 | struct sfc_mae_switch_port *port; |
| 427 | int rc; |
| 428 | |
| 429 | rte_spinlock_lock(&sfc_mae_switch.lock); |
| 430 | |
| 431 | domain = sfc_mae_find_switch_domain_by_id(switch_domain_id); |
| 432 | if (domain == NULL) { |
| 433 | rc = EINVAL; |
| 434 | goto fail_find_switch_domain_by_id; |
| 435 | } |
| 436 | |
| 437 | port = sfc_mae_find_switch_port_by_entity(domain, req->entity_mportp, |
| 438 | req->type); |
| 439 | if (port != NULL) |
| 440 | goto done; |
| 441 | |
| 442 | port = rte_zmalloc("sfc_mae_switch_port", sizeof(*port), 0); |
| 443 | if (port == NULL) { |
| 444 | rc = ENOMEM; |
| 445 | goto fail_mem_alloc; |
| 446 | } |
| 447 | |
| 448 | port->entity_mport.sel = req->entity_mportp->sel; |
| 449 | port->type = req->type; |
| 450 | |
| 451 | port->id = (domain->nb_ports++); |
| 452 | |
| 453 | TAILQ_INSERT_TAIL(&domain->ports, port, switch_domain_ports); |
| 454 | |
| 455 | done: |
| 456 | port->ethdev_mport = *req->ethdev_mportp; |
| 457 | port->ethdev_port_id = req->ethdev_port_id; |
| 458 | |
| 459 | memcpy(&port->data, &req->port_data, |
| 460 | sizeof(port->data)); |
| 461 | |
| 462 | switch (req->type) { |
| 463 | case SFC_MAE_SWITCH_PORT_INDEPENDENT: |
| 464 | if (port->data.indep.mae_admin) { |
| 465 | SFC_ASSERT(domain->mae_admin_port == NULL); |
| 466 | domain->mae_admin_port = port; |
| 467 | } |
| 468 | break; |
| 469 | case SFC_MAE_SWITCH_PORT_REPRESENTOR: |
| 470 | break; |
| 471 | default: |
| 472 | SFC_ASSERT(B_FALSE); |
| 473 | } |
| 474 | |
| 475 | *switch_port_id = port->id; |
| 476 | |
| 477 | rte_spinlock_unlock(&sfc_mae_switch.lock); |
no test coverage detected