1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2001-2021 Intel Corporation
5 #include "ice_common.h"
9 #define GPR_FLG_IDX 104
10 #define GPR_TSR_IDX 108
11 #define GPR_NN_IDX 109
12 #define GPR_HO_IDX 110
13 #define GPR_NP_IDX 111
15 static void _rt_tsr_set(struct ice_parser_rt *rt, u16 tsr)
17 rt->gpr[GPR_TSR_IDX] = tsr;
20 static void _rt_ho_set(struct ice_parser_rt *rt, u16 ho)
22 rt->gpr[GPR_HO_IDX] = ho;
23 ice_memcpy(&rt->gpr[GPR_HB_IDX], &rt->pkt_buf[ho], 32,
24 ICE_NONDMA_TO_NONDMA);
27 static void _rt_np_set(struct ice_parser_rt *rt, u16 pc)
29 rt->gpr[GPR_NP_IDX] = pc;
32 static void _rt_nn_set(struct ice_parser_rt *rt, u16 node)
34 rt->gpr[GPR_NN_IDX] = node;
37 static void _rt_flag_set(struct ice_parser_rt *rt, int idx)
42 rt->gpr[GPR_FLG_IDX + y] |= (u16)(1 << x);
46 * ice_parser_rt_reset - reset the parser runtime
47 * @rt: pointer to the parser runtime
49 void ice_parser_rt_reset(struct ice_parser_rt *rt)
51 struct ice_parser *psr = rt->psr;
52 struct ice_metainit_item *mi = &psr->mi_table[0];
55 ice_memset(rt, 0, sizeof(*rt), ICE_NONDMA_MEM);
57 _rt_tsr_set(rt, mi->tsr);
58 _rt_ho_set(rt, mi->ho);
59 _rt_np_set(rt, mi->pc);
60 _rt_nn_set(rt, mi->pg_rn);
62 for (i = 0; i < 64; i++) {
63 if ((mi->flags & (1ul << i)) != 0ul)
71 * ice_parser_rt_pktbuf_set - set a packet into parser runtime
72 * @rt: pointer to the parser runtime
73 * @pkt_buf: buffer with packet data
74 * @pkt_len: packet buffer length
76 void ice_parser_rt_pktbuf_set(struct ice_parser_rt *rt, const u8 *pkt_buf,
79 int len = min(ICE_PARSER_MAX_PKT_LEN, pkt_len);
80 u16 ho = rt->gpr[GPR_HO_IDX];
82 ice_memcpy(rt->pkt_buf, pkt_buf, len, ICE_NONDMA_TO_NONDMA);
83 rt->pkt_len = pkt_len;
85 ice_memcpy(&rt->gpr[GPR_HB_IDX], &rt->pkt_buf[ho], 32,
86 ICE_NONDMA_TO_NONDMA);
90 * ice_parser_rt_execute - parser execution routine
91 * @rt: pointer to the parser runtime
92 * @rslt: input/output parameter to save parser result
94 enum ice_status ice_parser_rt_execute(struct ice_parser_rt *rt,
95 struct ice_parser_result *rslt)
97 return ICE_ERR_NOT_IMPL;