Libiscsi: Adding abstraction to async functions
future iSER implementation will include different implementations for all socket relative function. in iSER we get event only when there is new entry in completion queue opposed to TCP that we get event when we can write to the socket. 1. iscsi_get_fd - TCP - returns socket fd. ISER - returns completion queue channel fd. 2. iscsi_service - TCP - processing the event type got from the socket and handles it. ISER - rearming the event mechanism in the completion queue and polling all available completion queue entries for process. 3. iscsi_which_events - TCP - returns which type of event the library is waiting for (Read, Write or both). ISER - in iSER we are waiting only for POLLIN event, hence this function always returns POLLIN. Signed-off-by: Roy Shterman <roysh@mellanox.com>
This commit is contained in:
committed by
Ronnie Sahlberg
parent
c85042bacb
commit
47b6881b97
@@ -395,6 +395,9 @@ struct iscsi_transport {
|
||||
struct iscsi_pdu* (*new_pdu)(struct iscsi_context *iscsi, size_t size);
|
||||
int (*disconnect)(struct iscsi_context *iscsi);
|
||||
void (*free_pdu)(struct iscsi_context *iscsi, struct iscsi_pdu *pdu);
|
||||
int (*service)(struct iscsi_context *iscsi, int revents);
|
||||
int (*get_fd)(struct iscsi_context *iscsi);
|
||||
int (*which_events)(struct iscsi_context *iscsi);
|
||||
};
|
||||
|
||||
struct tcp_transport {
|
||||
|
||||
28
lib/socket.c
28
lib/socket.c
@@ -390,6 +390,7 @@ iscsi_tcp_disconnect(struct iscsi_context *iscsi)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
iscsi_disconnect(struct iscsi_context *iscsi)
|
||||
{
|
||||
@@ -397,7 +398,7 @@ iscsi_disconnect(struct iscsi_context *iscsi)
|
||||
}
|
||||
|
||||
int
|
||||
iscsi_get_fd(struct iscsi_context *iscsi)
|
||||
iscsi_tcp_get_fd(struct iscsi_context *iscsi)
|
||||
{
|
||||
if (iscsi->old_iscsi) {
|
||||
return iscsi->old_iscsi->fd;
|
||||
@@ -406,7 +407,13 @@ iscsi_get_fd(struct iscsi_context *iscsi)
|
||||
}
|
||||
|
||||
int
|
||||
iscsi_which_events(struct iscsi_context *iscsi)
|
||||
iscsi_get_fd(struct iscsi_context *iscsi)
|
||||
{
|
||||
return iscsi->t->get_fd(iscsi);
|
||||
}
|
||||
|
||||
int
|
||||
iscsi_tcp_which_events(struct iscsi_context *iscsi)
|
||||
{
|
||||
int events = iscsi->is_connected ? POLLIN : POLLOUT;
|
||||
|
||||
@@ -426,6 +433,12 @@ iscsi_which_events(struct iscsi_context *iscsi)
|
||||
return events;
|
||||
}
|
||||
|
||||
int
|
||||
iscsi_which_events(struct iscsi_context *iscsi)
|
||||
{
|
||||
return iscsi->t->which_events(iscsi);
|
||||
}
|
||||
|
||||
int
|
||||
iscsi_queue_length(struct iscsi_context *iscsi)
|
||||
{
|
||||
@@ -823,7 +836,7 @@ iscsi_service_reconnect_if_loggedin(struct iscsi_context *iscsi)
|
||||
}
|
||||
|
||||
int
|
||||
iscsi_service(struct iscsi_context *iscsi, int revents)
|
||||
iscsi_tcp_service(struct iscsi_context *iscsi, int revents)
|
||||
{
|
||||
if (iscsi->fd < 0) {
|
||||
return 0;
|
||||
@@ -925,6 +938,12 @@ iscsi_service(struct iscsi_context *iscsi, int revents)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
iscsi_service(struct iscsi_context *iscsi, int revents)
|
||||
{
|
||||
return iscsi->t->service(iscsi, revents);
|
||||
}
|
||||
|
||||
static int iscsi_tcp_queue_pdu(struct iscsi_context *iscsi,
|
||||
struct iscsi_pdu *pdu)
|
||||
{
|
||||
@@ -1066,6 +1085,9 @@ void iscsi_init_tcp_transport(struct iscsi_context *iscsi)
|
||||
iscsi->t->new_pdu = iscsi_tcp_new_pdu;
|
||||
iscsi->t->disconnect = iscsi_tcp_disconnect;
|
||||
iscsi->t->free_pdu = iscsi_tcp_free_pdu;
|
||||
iscsi->t->service = iscsi_tcp_service;
|
||||
iscsi->t->get_fd = iscsi_tcp_get_fd;
|
||||
iscsi->t->which_events = iscsi_tcp_which_events;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user