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

Function sw_port_setup

dpdk/drivers/event/sw/sw_evdev.c:136–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134}
135
136static int
137sw_port_setup(struct rte_eventdev *dev, uint8_t port_id,
138 const struct rte_event_port_conf *conf)
139{
140 struct sw_evdev *sw = sw_pmd_priv(dev);
141 struct sw_port *p = &sw->ports[port_id];
142 char buf[RTE_RING_NAMESIZE];
143 unsigned int i;
144
145 struct rte_event_dev_info info;
146 sw_info_get(dev, &info);
147
148 /* detect re-configuring and return credits to instance if needed */
149 if (p->initialized) {
150 /* taking credits from pool is done one quanta at a time, and
151 * credits may be spend (counted in p->inflights) or still
152 * available in the port (p->inflight_credits). We must return
153 * the sum to no leak credits
154 */
155 int possible_inflights = p->inflight_credits + p->inflights;
156 rte_atomic32_sub(&sw->inflights, possible_inflights);
157 }
158
159 *p = (struct sw_port){0}; /* zero entire structure */
160 p->id = port_id;
161 p->sw = sw;
162
163 /* check to see if rings exists - port_setup() can be called multiple
164 * times legally (assuming device is stopped). If ring exists, free it
165 * to so it gets re-created with the correct size
166 */
167 snprintf(buf, sizeof(buf), "sw%d_p%u_%s", dev->data->dev_id,
168 port_id, "rx_worker_ring");
169 struct rte_event_ring *existing_ring = rte_event_ring_lookup(buf);
170 rte_event_ring_free(existing_ring);
171
172 p->rx_worker_ring = rte_event_ring_create(buf, MAX_SW_PROD_Q_DEPTH,
173 dev->data->socket_id,
174 RING_F_SP_ENQ | RING_F_SC_DEQ | RING_F_EXACT_SZ);
175 if (p->rx_worker_ring == NULL) {
176 SW_LOG_ERR("Error creating RX worker ring for port %d",
177 port_id);
178 return -1;
179 }
180
181 p->inflight_max = conf->new_event_threshold;
182 p->implicit_release = !(conf->event_port_cfg &
183 RTE_EVENT_PORT_CFG_DISABLE_IMPL_REL);
184
185 /* check if ring exists, same as rx_worker above */
186 snprintf(buf, sizeof(buf), "sw%d_p%u, %s", dev->data->dev_id,
187 port_id, "cq_worker_ring");
188 existing_ring = rte_event_ring_lookup(buf);
189 rte_event_ring_free(existing_ring);
190
191 p->cq_worker_ring = rte_event_ring_create(buf, conf->dequeue_depth,
192 dev->data->socket_id,
193 RING_F_SP_ENQ | RING_F_SC_DEQ | RING_F_EXACT_SZ);

Callers

nothing calls this directly

Calls 7

sw_pmd_privFunction · 0.85
sw_info_getFunction · 0.85
rte_atomic32_subFunction · 0.85
snprintfFunction · 0.85
rte_event_ring_lookupFunction · 0.85
rte_event_ring_freeFunction · 0.85
rte_event_ring_createFunction · 0.85

Tested by

no test coverage detected