* Attach to a port already registered by the primary process, which * makes sure that the same device would have the same port ID both * in the primary and secondary process. */
| 147 | * in the primary and secondary process. |
| 148 | */ |
| 149 | struct rte_eth_dev * |
| 150 | rte_eth_dev_attach_secondary(const char *name) |
| 151 | { |
| 152 | uint16_t i; |
| 153 | struct rte_eth_dev *eth_dev = NULL; |
| 154 | |
| 155 | /* Synchronize port attachment to primary port creation and release. */ |
| 156 | rte_spinlock_lock(rte_mcfg_ethdev_get_lock()); |
| 157 | |
| 158 | if (eth_dev_shared_data_prepare() == NULL) |
| 159 | goto unlock; |
| 160 | |
| 161 | for (i = 0; i < RTE_MAX_ETHPORTS; i++) { |
| 162 | if (strcmp(eth_dev_shared_data->data[i].name, name) == 0) |
| 163 | break; |
| 164 | } |
| 165 | if (i == RTE_MAX_ETHPORTS) { |
| 166 | RTE_ETHDEV_LOG(ERR, |
| 167 | "Device %s is not driven by the primary process\n", |
| 168 | name); |
| 169 | } else { |
| 170 | eth_dev = eth_dev_get(i); |
| 171 | RTE_ASSERT(eth_dev->data->port_id == i); |
| 172 | } |
| 173 | |
| 174 | unlock: |
| 175 | rte_spinlock_unlock(rte_mcfg_ethdev_get_lock()); |
| 176 | return eth_dev; |
| 177 | } |
| 178 | |
| 179 | int |
| 180 | rte_eth_dev_callback_process(struct rte_eth_dev *dev, |