| 134 | } |
| 135 | |
| 136 | static int |
| 137 | sw_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); |
nothing calls this directly
no test coverage detected