diff options
| author | Konstantin Khorenko <khorenko@virtuozzo.com> | 2018-08-10 13:11:42 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2018-08-11 15:25:15 -0400 |
| commit | 05364ca03cfd419caecb292fede20eb39667eaae (patch) | |
| tree | 134bb5ed07d0dccfb47220d5b760c5e2be8a673f /include | |
| parent | b70f1f3af47f4a21a25678f9ee587ed7986d62f8 (diff) | |
net/sctp: Make wrappers for accessing in/out streams
This patch introduces wrappers for accessing in/out streams indirectly.
This will enable to replace physically contiguous memory arrays
of streams with flexible arrays (or maybe any other appropriate
mechanism) which do memory allocation on a per-page basis.
Signed-off-by: Oleg Babin <obabin@virtuozzo.com>
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
| -rw-r--r-- | include/net/sctp/structs.h | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h index ab869e0d8326..6b2b8df8a1d2 100644 --- a/include/net/sctp/structs.h +++ b/include/net/sctp/structs.h | |||
| @@ -398,37 +398,35 @@ void sctp_stream_update(struct sctp_stream *stream, struct sctp_stream *new); | |||
| 398 | 398 | ||
| 399 | /* What is the current SSN number for this stream? */ | 399 | /* What is the current SSN number for this stream? */ |
| 400 | #define sctp_ssn_peek(stream, type, sid) \ | 400 | #define sctp_ssn_peek(stream, type, sid) \ |
| 401 | ((stream)->type[sid].ssn) | 401 | (sctp_stream_##type((stream), (sid))->ssn) |
| 402 | 402 | ||
| 403 | /* Return the next SSN number for this stream. */ | 403 | /* Return the next SSN number for this stream. */ |
| 404 | #define sctp_ssn_next(stream, type, sid) \ | 404 | #define sctp_ssn_next(stream, type, sid) \ |
| 405 | ((stream)->type[sid].ssn++) | 405 | (sctp_stream_##type((stream), (sid))->ssn++) |
| 406 | 406 | ||
| 407 | /* Skip over this ssn and all below. */ | 407 | /* Skip over this ssn and all below. */ |
| 408 | #define sctp_ssn_skip(stream, type, sid, ssn) \ | 408 | #define sctp_ssn_skip(stream, type, sid, ssn) \ |
| 409 | ((stream)->type[sid].ssn = ssn + 1) | 409 | (sctp_stream_##type((stream), (sid))->ssn = ssn + 1) |
| 410 | 410 | ||
| 411 | /* What is the current MID number for this stream? */ | 411 | /* What is the current MID number for this stream? */ |
| 412 | #define sctp_mid_peek(stream, type, sid) \ | 412 | #define sctp_mid_peek(stream, type, sid) \ |
| 413 | ((stream)->type[sid].mid) | 413 | (sctp_stream_##type((stream), (sid))->mid) |
| 414 | 414 | ||
| 415 | /* Return the next MID number for this stream. */ | 415 | /* Return the next MID number for this stream. */ |
| 416 | #define sctp_mid_next(stream, type, sid) \ | 416 | #define sctp_mid_next(stream, type, sid) \ |
| 417 | ((stream)->type[sid].mid++) | 417 | (sctp_stream_##type((stream), (sid))->mid++) |
| 418 | 418 | ||
| 419 | /* Skip over this mid and all below. */ | 419 | /* Skip over this mid and all below. */ |
| 420 | #define sctp_mid_skip(stream, type, sid, mid) \ | 420 | #define sctp_mid_skip(stream, type, sid, mid) \ |
| 421 | ((stream)->type[sid].mid = mid + 1) | 421 | (sctp_stream_##type((stream), (sid))->mid = mid + 1) |
| 422 | |||
| 423 | #define sctp_stream_in(asoc, sid) (&(asoc)->stream.in[sid]) | ||
| 424 | 422 | ||
| 425 | /* What is the current MID_uo number for this stream? */ | 423 | /* What is the current MID_uo number for this stream? */ |
| 426 | #define sctp_mid_uo_peek(stream, type, sid) \ | 424 | #define sctp_mid_uo_peek(stream, type, sid) \ |
| 427 | ((stream)->type[sid].mid_uo) | 425 | (sctp_stream_##type((stream), (sid))->mid_uo) |
| 428 | 426 | ||
| 429 | /* Return the next MID_uo number for this stream. */ | 427 | /* Return the next MID_uo number for this stream. */ |
| 430 | #define sctp_mid_uo_next(stream, type, sid) \ | 428 | #define sctp_mid_uo_next(stream, type, sid) \ |
| 431 | ((stream)->type[sid].mid_uo++) | 429 | (sctp_stream_##type((stream), (sid))->mid_uo++) |
| 432 | 430 | ||
| 433 | /* | 431 | /* |
| 434 | * Pointers to address related SCTP functions. | 432 | * Pointers to address related SCTP functions. |
| @@ -1463,6 +1461,23 @@ struct sctp_stream { | |||
| 1463 | struct sctp_stream_interleave *si; | 1461 | struct sctp_stream_interleave *si; |
| 1464 | }; | 1462 | }; |
| 1465 | 1463 | ||
| 1464 | static inline struct sctp_stream_out *sctp_stream_out( | ||
| 1465 | const struct sctp_stream *stream, | ||
| 1466 | __u16 sid) | ||
| 1467 | { | ||
| 1468 | return ((struct sctp_stream_out *)(stream->out)) + sid; | ||
| 1469 | } | ||
| 1470 | |||
| 1471 | static inline struct sctp_stream_in *sctp_stream_in( | ||
| 1472 | const struct sctp_stream *stream, | ||
| 1473 | __u16 sid) | ||
| 1474 | { | ||
| 1475 | return ((struct sctp_stream_in *)(stream->in)) + sid; | ||
| 1476 | } | ||
| 1477 | |||
| 1478 | #define SCTP_SO(s, i) sctp_stream_out((s), (i)) | ||
| 1479 | #define SCTP_SI(s, i) sctp_stream_in((s), (i)) | ||
| 1480 | |||
| 1466 | #define SCTP_STREAM_CLOSED 0x00 | 1481 | #define SCTP_STREAM_CLOSED 0x00 |
| 1467 | #define SCTP_STREAM_OPEN 0x01 | 1482 | #define SCTP_STREAM_OPEN 0x01 |
| 1468 | 1483 | ||
