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

Function memif_connect_client

dpdk/drivers/net/memif/memif_socket.c:1117–1202  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1115}
1116
1117int
1118memif_connect_client(struct rte_eth_dev *dev)
1119{
1120 int sockfd;
1121 int ret;
1122 uint32_t sunlen;
1123 struct sockaddr_un sun = { 0 };
1124 struct pmd_internals *pmd = dev->data->dev_private;
1125
1126 memset(pmd->local_disc_string, 0, ETH_MEMIF_DISC_STRING_SIZE);
1127 memset(pmd->remote_disc_string, 0, ETH_MEMIF_DISC_STRING_SIZE);
1128 pmd->flags &= ~ETH_MEMIF_FLAG_DISABLED;
1129
1130 sockfd = socket(AF_UNIX, SOCK_SEQPACKET, 0);
1131 if (sockfd < 0) {
1132 MIF_LOG(ERR, "Failed to open socket.");
1133 return -1;
1134 }
1135
1136 sun.sun_family = AF_UNIX;
1137 sunlen = sizeof(struct sockaddr_un);
1138 if (pmd->flags & ETH_MEMIF_FLAG_SOCKET_ABSTRACT) {
1139 /* abstract address */
1140 sun.sun_path[0] = '\0';
1141 strlcpy(sun.sun_path + 1, pmd->socket_filename, MEMIF_SOCKET_UN_SIZE - 1);
1142 sunlen = RTE_MIN(strlen(pmd->socket_filename) + 1,
1143 MEMIF_SOCKET_UN_SIZE) +
1144 sizeof(sun) - sizeof(sun.sun_path);
1145 } else {
1146 strlcpy(sun.sun_path, pmd->socket_filename, MEMIF_SOCKET_UN_SIZE);
1147 }
1148
1149 ret = connect(sockfd, (struct sockaddr *)&sun, sunlen);
1150 if (ret < 0) {
1151 MIF_LOG(ERR, "Failed to connect socket: %s.", pmd->socket_filename);
1152 goto error;
1153 }
1154
1155 MIF_LOG(DEBUG, "Memif socket: %s connected.", pmd->socket_filename);
1156
1157 pmd->cc = rte_zmalloc("memif-cc",
1158 sizeof(struct memif_control_channel), 0);
1159 if (pmd->cc == NULL) {
1160 MIF_LOG(ERR, "Failed to allocate control channel.");
1161 goto error;
1162 }
1163
1164 /* Allocate interrupt instance */
1165 pmd->cc->intr_handle =
1166 rte_intr_instance_alloc(RTE_INTR_INSTANCE_F_SHARED);
1167 if (pmd->cc->intr_handle == NULL) {
1168 MIF_LOG(ERR, "Failed to allocate intr handle");
1169 goto error;
1170 }
1171
1172 if (rte_intr_fd_set(pmd->cc->intr_handle, sockfd))
1173 goto error;
1174

Callers 1

memif_dev_startFunction · 0.85

Calls 12

memsetFunction · 0.85
rte_zmallocFunction · 0.85
rte_intr_instance_allocFunction · 0.85
rte_intr_fd_setFunction · 0.85
rte_intr_type_setFunction · 0.85
rte_intr_instance_freeFunction · 0.85
rte_freeFunction · 0.85
socketClass · 0.50
strlcpyFunction · 0.50
connectFunction · 0.50
closeFunction · 0.50

Tested by

no test coverage detected