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

Function sfc_mae_assign_switch_domain

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

Source from the content-addressed store, hash-verified

198}
199
200int
201sfc_mae_assign_switch_domain(struct sfc_adapter *sa,
202 uint16_t *switch_domain_id)
203{
204 struct sfc_hw_switch_id *hw_switch_id;
205 struct sfc_mae_switch_domain *domain;
206 int rc;
207
208 rte_spinlock_lock(&sfc_mae_switch.lock);
209
210 rc = sfc_hw_switch_id_init(sa, &hw_switch_id);
211 if (rc != 0)
212 goto fail_hw_switch_id_init;
213
214 domain = sfc_mae_find_switch_domain_by_hw_switch_id(hw_switch_id);
215 if (domain != NULL) {
216 sfc_hw_switch_id_fini(sa, hw_switch_id);
217 goto done;
218 }
219
220 domain = rte_zmalloc("sfc_mae_switch_domain", sizeof(*domain), 0);
221 if (domain == NULL) {
222 rc = ENOMEM;
223 goto fail_mem_alloc;
224 }
225
226 /*
227 * This code belongs to driver init path, that is, negation is
228 * done at the end of the path by sfc_eth_dev_init(). RTE APIs
229 * negate error codes, so drop negation here.
230 */
231 rc = -rte_eth_switch_domain_alloc(&domain->id);
232 if (rc != 0)
233 goto fail_domain_alloc;
234
235 domain->hw_switch_id = hw_switch_id;
236
237 TAILQ_INIT(&domain->ports);
238
239 TAILQ_INSERT_TAIL(&sfc_mae_switch.domains, domain, entries);
240
241done:
242 *switch_domain_id = domain->id;
243
244 rte_spinlock_unlock(&sfc_mae_switch.lock);
245
246 return 0;
247
248fail_domain_alloc:
249 rte_free(domain);
250
251fail_mem_alloc:
252 sfc_hw_switch_id_fini(sa, hw_switch_id);
253
254fail_hw_switch_id_init:
255 rte_spinlock_unlock(&sfc_mae_switch.lock);
256 return rc;
257}

Callers 1

sfc_mae_attachFunction · 0.85

Calls 8

sfc_hw_switch_id_initFunction · 0.85
sfc_hw_switch_id_finiFunction · 0.85
rte_zmallocFunction · 0.85
rte_freeFunction · 0.85
rte_spinlock_lockFunction · 0.50
rte_spinlock_unlockFunction · 0.50

Tested by

no test coverage detected