Lines Matching refs:len

40 static uint32_t idx_occupied(uint32_t len, uint32_t a, uint32_t b)  in idx_occupied()  argument
43 return (b > a) ? (len - (b - a)) : (a - b); in idx_occupied()
46 static inline void cache_wb(void *data, size_t len, uint32_t flags) in cache_wb() argument
50 sys_cache_data_flush_range(data, len); in cache_wb()
54 static inline void cache_inv(void *data, size_t len, uint32_t flags) in cache_inv() argument
58 sys_cache_data_invd_range(data, len); in cache_inv()
89 uint32_t len = blen - sizeof(struct spsc_pbuf_common); in get_len() local
93 return len - sizeof(struct spsc_pbuf_ext_cache); in get_len()
96 return len - sizeof(struct spsc_pbuf_ext_nocache); in get_len()
124 pb->common.len = get_len(blen, flags); in spsc_pbuf_init()
136 int spsc_pbuf_alloc(struct spsc_pbuf *pb, uint16_t len, char **buf) in spsc_pbuf_alloc() argument
139 const uint32_t pblen = pb->common.len; in spsc_pbuf_alloc()
145 uint32_t space = len + LEN_SZ; /* data + length field */ in spsc_pbuf_alloc()
147 if (len == 0 || len > SPSC_PBUF_MAX_LEN) { in spsc_pbuf_alloc()
166 if (len == SPSC_PBUF_MAX_LEN) { in spsc_pbuf_alloc()
195 len = MIN(len, MAX(free_space - (int32_t)LEN_SZ, 0)); in spsc_pbuf_alloc()
198 return len; in spsc_pbuf_alloc()
201 void spsc_pbuf_commit(struct spsc_pbuf *pb, uint16_t len) in spsc_pbuf_commit() argument
203 if (len == 0) { in spsc_pbuf_commit()
208 const uint32_t pblen = pb->common.len; in spsc_pbuf_commit()
215 sys_put_be16(len, &data_loc[wr_idx]); in spsc_pbuf_commit()
217 cache_wb(&data_loc[wr_idx], len + LEN_SZ, flags); in spsc_pbuf_commit()
219 wr_idx += len + LEN_SZ; in spsc_pbuf_commit()
228 int spsc_pbuf_write(struct spsc_pbuf *pb, const char *buf, uint16_t len) in spsc_pbuf_write() argument
233 if (len >= SPSC_PBUF_MAX_LEN) { in spsc_pbuf_write()
237 outlen = spsc_pbuf_alloc(pb, len, &pbuf); in spsc_pbuf_write()
238 if (outlen != len) { in spsc_pbuf_write()
242 memcpy(pbuf, buf, len); in spsc_pbuf_write()
244 spsc_pbuf_commit(pb, len); in spsc_pbuf_write()
246 return len; in spsc_pbuf_write()
252 const uint32_t pblen = pb->common.len; in spsc_pbuf_claim()
282 uint16_t len; in spsc_pbuf_claim() local
305 cache_inv(&data_loc[rd_idx], sizeof(len), flags); in spsc_pbuf_claim()
308 len = sys_get_be16(&data_loc[rd_idx]); in spsc_pbuf_claim()
311 __ASSERT_NO_MSG(bytes_stored >= (len + LEN_SZ)); in spsc_pbuf_claim()
313 cache_inv(&data_loc[rd_idx + LEN_SZ], len, flags); in spsc_pbuf_claim()
316 return len; in spsc_pbuf_claim()
319 void spsc_pbuf_free(struct spsc_pbuf *pb, uint16_t len) in spsc_pbuf_free() argument
322 const uint32_t pblen = pb->common.len; in spsc_pbuf_free()
326 uint16_t rd_idx = *rd_idx_loc + len + LEN_SZ; in spsc_pbuf_free()
352 int spsc_pbuf_read(struct spsc_pbuf *pb, char *buf, uint16_t len) in spsc_pbuf_read() argument
365 if (len < plen) { in spsc_pbuf_read()