* Handle server pmd socket interrupts. */
| 30 | * Handle server pmd socket interrupts. |
| 31 | */ |
| 32 | static void |
| 33 | mlx5_pmd_socket_handle(void *cb __rte_unused) |
| 34 | { |
| 35 | int conn_sock; |
| 36 | int ret; |
| 37 | struct cmsghdr *cmsg = NULL; |
| 38 | uint32_t data[MLX5_SENDMSG_MAX / sizeof(uint32_t)]; |
| 39 | struct rte_flow *flow_ptr = NULL; |
| 40 | uint8_t buf[CMSG_SPACE(sizeof(int))] = { 0 }; |
| 41 | struct iovec io = { |
| 42 | .iov_base = data, |
| 43 | .iov_len = sizeof(data), |
| 44 | }; |
| 45 | struct msghdr msg = { |
| 46 | .msg_iov = &io, |
| 47 | .msg_iovlen = 1, |
| 48 | .msg_control = buf, |
| 49 | .msg_controllen = sizeof(buf), |
| 50 | }; |
| 51 | |
| 52 | uint32_t port_id; |
| 53 | int fd; |
| 54 | FILE *file = NULL; |
| 55 | struct rte_eth_dev *dev; |
| 56 | struct rte_flow_error err; |
| 57 | struct mlx5_flow_dump_req *dump_req; |
| 58 | struct mlx5_flow_dump_ack *dump_ack; |
| 59 | |
| 60 | memset(data, 0, sizeof(data)); |
| 61 | /* Accept the connection from the client. */ |
| 62 | conn_sock = accept(server_socket, NULL, NULL); |
| 63 | if (conn_sock < 0) { |
| 64 | DRV_LOG(WARNING, "connection failed: %s", strerror(errno)); |
| 65 | return; |
| 66 | } |
| 67 | ret = recvmsg(conn_sock, &msg, MSG_WAITALL); |
| 68 | if (ret != sizeof(struct mlx5_flow_dump_req)) { |
| 69 | DRV_LOG(WARNING, "wrong message received: %s", |
| 70 | strerror(errno)); |
| 71 | goto error; |
| 72 | } |
| 73 | |
| 74 | /* Receive file descriptor. */ |
| 75 | cmsg = CMSG_FIRSTHDR(&msg); |
| 76 | if (cmsg == NULL || cmsg->cmsg_type != SCM_RIGHTS || |
| 77 | cmsg->cmsg_len < sizeof(int)) { |
| 78 | DRV_LOG(WARNING, "invalid file descriptor message"); |
| 79 | goto error; |
| 80 | } |
| 81 | memcpy(&fd, CMSG_DATA(cmsg), sizeof(fd)); |
| 82 | file = fdopen(fd, "w"); |
| 83 | if (!file) { |
| 84 | DRV_LOG(WARNING, "Failed to open file"); |
| 85 | goto error; |
| 86 | } |
| 87 | /* Receive port number. */ |
| 88 | if (msg.msg_iovlen != 1 || msg.msg_iov->iov_len < sizeof(uint16_t)) { |
| 89 | DRV_LOG(WARNING, "wrong port number message"); |
nothing calls this directly
no test coverage detected