Lines Matching refs:pb
62 static uint32_t *get_rd_idx_loc(struct spsc_pbuf *pb, uint32_t flags) in get_rd_idx_loc() argument
64 return &pb->common.rd_idx; in get_rd_idx_loc()
67 static uint32_t *get_wr_idx_loc(struct spsc_pbuf *pb, uint32_t flags) in get_wr_idx_loc() argument
71 return &pb->ext.cache.wr_idx; in get_wr_idx_loc()
74 return &pb->ext.nocache.wr_idx; in get_wr_idx_loc()
77 static uint8_t *get_data_loc(struct spsc_pbuf *pb, uint32_t flags) in get_data_loc() argument
81 return pb->ext.cache.data; in get_data_loc()
84 return pb->ext.nocache.data; in get_data_loc()
119 struct spsc_pbuf *pb = buf; in spsc_pbuf_init() local
120 uint32_t *wr_idx_loc = get_wr_idx_loc(pb, flags); in spsc_pbuf_init()
122 __ASSERT_NO_MSG(blen > (sizeof(*pb) + LEN_SZ)); in spsc_pbuf_init()
124 pb->common.len = get_len(blen, flags); in spsc_pbuf_init()
125 pb->common.rd_idx = 0; in spsc_pbuf_init()
126 pb->common.flags = flags; in spsc_pbuf_init()
130 cache_wb(&pb->common, sizeof(pb->common), flags); in spsc_pbuf_init()
133 return pb; 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()
140 const uint32_t flags = pb->common.flags; in spsc_pbuf_alloc()
141 uint32_t *rd_idx_loc = get_rd_idx_loc(pb, flags); in spsc_pbuf_alloc()
142 uint32_t *wr_idx_loc = get_wr_idx_loc(pb, flags); in spsc_pbuf_alloc()
143 uint8_t *data_loc = get_data_loc(pb, flags); in spsc_pbuf_alloc()
201 void spsc_pbuf_commit(struct spsc_pbuf *pb, uint16_t len) in spsc_pbuf_commit() argument
208 const uint32_t pblen = pb->common.len; in spsc_pbuf_commit()
209 const uint32_t flags = pb->common.flags; in spsc_pbuf_commit()
210 uint32_t *wr_idx_loc = get_wr_idx_loc(pb, flags); in spsc_pbuf_commit()
211 uint8_t *data_loc = get_data_loc(pb, flags); in spsc_pbuf_commit()
228 int spsc_pbuf_write(struct spsc_pbuf *pb, const char *buf, uint16_t len) in spsc_pbuf_write() argument
237 outlen = spsc_pbuf_alloc(pb, len, &pbuf); in spsc_pbuf_write()
244 spsc_pbuf_commit(pb, len); in spsc_pbuf_write()
249 uint16_t spsc_pbuf_claim(struct spsc_pbuf *pb, char **buf) in spsc_pbuf_claim() argument
252 const uint32_t pblen = pb->common.len; in spsc_pbuf_claim()
253 const uint32_t flags = pb->common.flags; in spsc_pbuf_claim()
254 uint32_t *rd_idx_loc = get_rd_idx_loc(pb, flags); in spsc_pbuf_claim()
255 uint32_t *wr_idx_loc = get_wr_idx_loc(pb, flags); in spsc_pbuf_claim()
256 uint8_t *data_loc = get_data_loc(pb, flags); in spsc_pbuf_claim()
276 pb->common.flags = SET_UTILIZATION(flags, bytes_stored); in spsc_pbuf_claim()
278 cache_wb(&pb->common.flags, sizeof(pb->common.flags), flags); 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()
323 const uint32_t flags = pb->common.flags; in spsc_pbuf_free()
324 uint32_t *rd_idx_loc = get_rd_idx_loc(pb, flags); in spsc_pbuf_free()
325 uint32_t *wr_idx_loc = get_wr_idx_loc(pb, flags); in spsc_pbuf_free()
327 uint8_t *data_loc = get_data_loc(pb, flags); in spsc_pbuf_free()
352 int spsc_pbuf_read(struct spsc_pbuf *pb, char *buf, uint16_t len) in spsc_pbuf_read() argument
355 uint16_t plen = spsc_pbuf_claim(pb, &pkt); in spsc_pbuf_read()
371 spsc_pbuf_free(pb, plen); in spsc_pbuf_read()
376 int spsc_pbuf_get_utilization(struct spsc_pbuf *pb) in spsc_pbuf_get_utilization() argument
382 cache_inv(&pb->common.flags, sizeof(pb->common.flags), pb->common.flags); in spsc_pbuf_get_utilization()
385 return GET_UTILIZATION(pb->common.flags); in spsc_pbuf_get_utilization()