| 191 | } |
| 192 | |
| 193 | int |
| 194 | virtio_send_command(struct virtnet_ctl *cvq, struct virtio_pmd_ctrl *ctrl, int *dlen, int pkt_num) |
| 195 | { |
| 196 | virtio_net_ctrl_ack status = ~0; |
| 197 | struct virtio_pmd_ctrl *result; |
| 198 | struct virtqueue *vq; |
| 199 | |
| 200 | ctrl->status = status; |
| 201 | |
| 202 | if (!cvq) { |
| 203 | PMD_INIT_LOG(ERR, "Control queue is not supported."); |
| 204 | return -1; |
| 205 | } |
| 206 | |
| 207 | rte_spinlock_lock(&cvq->lock); |
| 208 | vq = virtnet_cq_to_vq(cvq); |
| 209 | |
| 210 | PMD_INIT_LOG(DEBUG, "vq->vq_desc_head_idx = %d, status = %d, " |
| 211 | "vq->hw->cvq = %p vq = %p", |
| 212 | vq->vq_desc_head_idx, status, vq->hw->cvq, vq); |
| 213 | |
| 214 | if (vq->vq_free_cnt < pkt_num + 2 || pkt_num < 1) { |
| 215 | rte_spinlock_unlock(&cvq->lock); |
| 216 | return -1; |
| 217 | } |
| 218 | |
| 219 | memcpy(cvq->hdr_mz->addr, ctrl, sizeof(struct virtio_pmd_ctrl)); |
| 220 | |
| 221 | if (virtio_with_packed_queue(vq->hw)) |
| 222 | result = virtio_send_command_packed(cvq, ctrl, dlen, pkt_num); |
| 223 | else |
| 224 | result = virtio_send_command_split(cvq, ctrl, dlen, pkt_num); |
| 225 | |
| 226 | rte_spinlock_unlock(&cvq->lock); |
| 227 | return result->status; |
| 228 | } |
| 229 |
no test coverage detected