MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sfc_mae_assign_switch_port

Function sfc_mae_assign_switch_port

dpdk/drivers/net/sfc/sfc_switch.c:420–485  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

418}
419
420int
421sfc_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
455done:
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);

Callers 3

sfc_mae_attachFunction · 0.85

Calls 6

rte_zmallocFunction · 0.85
rte_spinlock_lockFunction · 0.50
memcpyFunction · 0.50
rte_spinlock_unlockFunction · 0.50

Tested by

no test coverage detected