2 * Copyright (c) 2016 Intel Corporation.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
23 static inline struct rte_mbuf **
24 tcp_txq_get_nxt_objs(const struct tle_tcp_stream *s, uint32_t *num)
26 uint32_t cnt, head, mask, sz, tail;
32 head = r->cons.head & mask;
33 tail = r->prod.tail & mask;
35 cnt = (tail >= head) ? tail - head : sz - head;
38 return (struct rte_mbuf **)(r->ring + head);
41 static inline struct rte_mbuf **
42 tcp_txq_get_una_objs(const struct tle_tcp_stream *s, uint32_t *num)
44 uint32_t cnt, head, mask, sz, tail;
50 head = r->prod.tail & mask;
51 tail = r->cons.tail & mask;
53 cnt = (head >= tail) ? head - tail : sz - tail;
56 return (struct rte_mbuf **)(r->ring + tail);
60 tcp_txq_set_nxt_head(struct tle_tcp_stream *s, uint32_t num)
69 tcp_txq_rst_nxt_head(struct tle_tcp_stream *s)
74 r->cons.head = r->cons.tail;
78 tcp_txq_set_una_tail(struct tle_tcp_stream *s, uint32_t num)
87 static inline uint32_t
88 tcp_txq_nxt_cnt(struct tle_tcp_stream *s)
93 return (r->prod.tail - r->cons.head) & r->prod.mask;
97 txs_enqueue(struct tle_ctx *ctx, struct tle_tcp_stream *s)
102 if (rte_atomic32_add_return(&s->tx.arm, 1) == 1) {
103 r = CTX_TCP_TSQ(ctx);
104 n = rte_ring_enqueue_burst(r, (void * const *)&s, 1);
109 static inline uint32_t
110 txs_dequeue_bulk(struct tle_ctx *ctx, struct tle_tcp_stream *s[], uint32_t num)
114 r = CTX_TCP_TSQ(ctx);
115 return rte_ring_dequeue_burst(r, (void **)s, num);
122 #endif /* _TCP_TXQ_H_ */