3 * Copyright 2007 Free Software Foundation, Inc.
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef INCLUDED_DBSM_H
19 #define INCLUDED_DBSM_H
22 * Double Buffering State Machine
29 typedef struct _dbsm dbsm_t;
32 * pointer to function that does packet inspection.
34 * If one of these returns true, it means that the s/w
35 * handled that packet, and that it should NOT be passed
36 * on to the normal destination port.
38 typedef bool (*inspector_t)(dbsm_t *sm, int buf_this);
40 bool dbsm_nop_inspector(dbsm_t *sm, int buf_this); // returns false
51 * double buffer state machine
55 uint8_t buf0; // Must be even. This machine uses buf0 and buf0+1
59 buf_cmd_args_t recv_args;
60 buf_cmd_args_t send_args;
62 uint32_t precomputed_receive_to_buf_ctrl_word[2];
63 uint32_t precomputed_send_from_buf_ctrl_word[2];
67 void dbsm_init(dbsm_t *sm, int buf0,
68 const buf_cmd_args_t *recv, const buf_cmd_args_t *send,
71 void dbsm_start(dbsm_t *sm);
72 void dbsm_stop(dbsm_t *sm);
73 void dbsm_process_status(dbsm_t *sm, uint32_t status);
74 void dbsm_handle_tx_underrun(dbsm_t *sm);
75 void dbsm_handle_rx_overrun(dbsm_t *sm);
78 * The cpu calls this when it want to ensure that it can send a buffer
79 * to the same destination being used by this state machine.
81 * If neither buffer is EMPTYING it returns immediately. If a buffer
82 * is EMPYTING, it waits for the h/w to transition to the DONE or
85 * When this function returns, the caller queues it's buffer and busy
86 * waits for it to complete.
88 void dbsm_wait_for_opening(dbsm_t *sm);
90 #endif /* INCLUDED_DBSM_H */