net: add generic transfer statistics

This commit is contained in:
Thomas Schoebel-Theuer 2015-06-16 08:25:05 +02:00
parent 87aee9eff6
commit f18df7c952
2 changed files with 14 additions and 0 deletions

View File

@ -457,6 +457,7 @@ int _mars_send_raw(struct mars_socket *msock, const void *buf, int len, int flag
sleeptime = 1000 / HZ;
}
msock->s_send_bytes += sent;
if (status >= 0)
status = sent;
@ -642,6 +643,7 @@ int _mars_recv_raw(struct mars_socket *msock, void *buf, int minlen, int maxlen,
sleeptime = 1000 / HZ;
}
status = done;
msock->s_recv_bytes += done;
MARS_IO("#%d got %d bytes\n", msock->s_debug_nr, done);

View File

@ -43,9 +43,21 @@ extern bool mars_net_is_alive;
* Later, some buffering was added in order to take advantage of
* kernel_sendpage().
* Caching of meta description has also been added.
*
* Notice: we have a slightly restricted parallelism model.
* One sender and one receiver thread may work in parallel
* on the same socket instance. At low level, there must not exist
* multiple readers in parallel to each other, or multiple
* writers in parallel to each other. Otherwise, higher level
* protocol sequences would be disturbed anyway.
* When needed, you may achieve higher parallelism by doing your own
* semaphore locking around mars_{send,recv}_struct() or even longer
* sequences of subsets of your high-level protocol.
*/
struct mars_socket {
struct socket *s_socket;
u64 s_send_bytes;
u64 s_recv_bytes;
void *s_buffer;
atomic_t s_count;
int s_pos;