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.
15 #include <rte_malloc.h>
16 #include <rte_errno.h>
18 #include "tcp_stream.h"
21 #define OFO_FRACTION 4
23 #define OFO_DB_MAX 0x20U
25 #define OFODB_OBJ_MIN 8U
26 #define OFODB_OBJ_MAX 0x20U
28 #define OFO_OBJ_MAX (OFODB_OBJ_MAX * OFO_DB_MAX)
31 calc_ofo_size(uint32_t nobj, uint32_t ndb)
33 uint32_t dsz, osz, sz;
34 const struct ofo *ofo = NULL;
36 osz = sizeof(*ofo) + sizeof(ofo->db[0]) * ndb;
37 dsz = sizeof(ofo->db[0].obj[0]) * nobj * ndb;
43 tcp_ofo_calc_elems(uint32_t nbufs, uint32_t *nobj, uint32_t *ndb, uint32_t *sz)
47 n = nbufs / OFO_FRACTION;
48 n = RTE_MAX(n, OFODB_OBJ_MIN);
49 n = RTE_MIN(n, OFO_OBJ_MAX);
51 no = OFODB_OBJ_MIN / 2;
55 } while (nd > OFO_DB_MAX);
59 *sz = calc_ofo_size(no, nd);
63 tcp_ofo_init(struct ofo *ofo, uint32_t nobj, uint32_t ndb)
66 struct rte_mbuf **obj;
68 obj = (struct rte_mbuf **)&ofo->db[ndb];
69 for (i = 0; i != ndb; i++) {
70 ofo->db[i].nb_max = nobj;
71 ofo->db[i].obj = obj + i * nobj;