Lines Matching refs:mock

13 	struct modem_backend_mock *mock = (struct modem_backend_mock *)data;  in modem_backend_mock_open()  local
15 modem_pipe_notify_opened(&mock->pipe); in modem_backend_mock_open()
19 static bool modem_backend_mock_update(struct modem_backend_mock *mock, const uint8_t *buf, in modem_backend_mock_update() argument
22 if (mock->transaction == NULL) { in modem_backend_mock_update()
27 __ASSERT(buf[i] == mock->transaction->get[mock->transaction_match_cnt], in modem_backend_mock_update()
30 mock->transaction_match_cnt++; in modem_backend_mock_update()
31 if (mock->transaction_match_cnt == mock->transaction->get_size) { in modem_backend_mock_update()
41 struct modem_backend_mock *mock = (struct modem_backend_mock *)data; in modem_backend_mock_transmit() local
44 size = (mock->limit < size) ? mock->limit : size; in modem_backend_mock_transmit()
46 if (mock->bridge) { in modem_backend_mock_transmit()
47 struct modem_backend_mock *t_mock = mock->bridge; in modem_backend_mock_transmit()
51 k_work_submit(&mock->transmit_idle_work); in modem_backend_mock_transmit()
55 ret = ring_buf_put(&mock->tx_rb, buf, size); in modem_backend_mock_transmit()
56 if (modem_backend_mock_update(mock, buf, size)) { in modem_backend_mock_transmit()
57 modem_backend_mock_put(mock, mock->transaction->put, in modem_backend_mock_transmit()
58 mock->transaction->put_size); in modem_backend_mock_transmit()
60 mock->transaction = NULL; in modem_backend_mock_transmit()
63 k_work_submit(&mock->transmit_idle_work); in modem_backend_mock_transmit()
69 struct modem_backend_mock *mock = (struct modem_backend_mock *)data; in modem_backend_mock_receive() local
71 size = (mock->limit < size) ? mock->limit : size; in modem_backend_mock_receive()
72 return ring_buf_get(&mock->rx_rb, buf, size); in modem_backend_mock_receive()
77 struct modem_backend_mock *mock = (struct modem_backend_mock *)data; in modem_backend_mock_close() local
79 modem_pipe_notify_closed(&mock->pipe); in modem_backend_mock_close()
92 struct modem_backend_mock *mock = in modem_backend_mock_receive_ready_handler() local
95 modem_pipe_notify_receive_ready(&mock->pipe); in modem_backend_mock_receive_ready_handler()
100 struct modem_backend_mock *mock = in modem_backend_mock_transmit_idle_handler() local
103 modem_pipe_notify_transmit_idle(&mock->pipe); in modem_backend_mock_transmit_idle_handler()
106 struct modem_pipe *modem_backend_mock_init(struct modem_backend_mock *mock, in modem_backend_mock_init() argument
109 memset(mock, 0, sizeof(*mock)); in modem_backend_mock_init()
111 ring_buf_init(&mock->rx_rb, config->rx_buf_size, config->rx_buf); in modem_backend_mock_init()
112 ring_buf_init(&mock->tx_rb, config->tx_buf_size, config->tx_buf); in modem_backend_mock_init()
113 k_work_init(&mock->receive_ready_work, modem_backend_mock_receive_ready_handler); in modem_backend_mock_init()
114 k_work_init(&mock->transmit_idle_work, modem_backend_mock_transmit_idle_handler); in modem_backend_mock_init()
115 mock->limit = config->limit; in modem_backend_mock_init()
116 modem_pipe_init(&mock->pipe, mock, &modem_backend_mock_api); in modem_backend_mock_init()
117 return &mock->pipe; in modem_backend_mock_init()
120 struct modem_pipe *modem_backend_mock_get_pipe(struct modem_backend_mock *mock) in modem_backend_mock_get_pipe() argument
122 return &mock->pipe; in modem_backend_mock_get_pipe()
125 void modem_backend_mock_reset(struct modem_backend_mock *mock) in modem_backend_mock_reset() argument
127 ring_buf_reset(&mock->rx_rb); in modem_backend_mock_reset()
128 ring_buf_reset(&mock->tx_rb); in modem_backend_mock_reset()
129 mock->transaction = NULL; in modem_backend_mock_reset()
130 mock->transaction_match_cnt = 0; in modem_backend_mock_reset()
133 int modem_backend_mock_get(struct modem_backend_mock *mock, uint8_t *buf, size_t size) in modem_backend_mock_get() argument
135 return ring_buf_get(&mock->tx_rb, buf, size); in modem_backend_mock_get()
138 void modem_backend_mock_put(struct modem_backend_mock *mock, const uint8_t *buf, size_t size) in modem_backend_mock_put() argument
140 __ASSERT(ring_buf_put(&mock->rx_rb, buf, size) == size, in modem_backend_mock_put()
143 k_work_submit(&mock->receive_ready_work); in modem_backend_mock_put()
146 void modem_backend_mock_prime(struct modem_backend_mock *mock, in modem_backend_mock_prime() argument
149 mock->transaction = transaction; in modem_backend_mock_prime()
150 mock->transaction_match_cnt = 0; in modem_backend_mock_prime()