Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b9104dc

Browse files
ON-16996: Provide shared sbseq for all shrub clients.
All clients need the global sbseq that matches the HW events to allow wakeups to be handled properly.
1 parent 84811a6 commit b9104dc

File tree

6 files changed

+39
-18
lines changed

6 files changed

+39
-18
lines changed

‎src/include/etherfabric/internal/shrub_client.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,16 @@ void ef_shrub_client_close(struct ef_shrub_client* client);
6262
*
6363
* client: connection providing the buffer
6464
* buffer_id: provides an identifier to be used when releasing the buffer
65+
* sentinel: sentinel value for the buffer
66+
* sbseq: superbuf sequence number associated with the buffer
6567
*
6668
* Returns zero on success, or negative error codes including
6769
* -EAGAIN no buffers available
6870
*/
6971
int ef_shrub_client_acquire_buffer(struct ef_shrub_client* client,
7072
uint32_t* buffer_id,
71-
bool* sentinel);
73+
bool* sentinel,
74+
uint32_t* sbseq);
7275

7376
/* Indicate that the buffer is no longer needed.
7477
*
@@ -93,4 +96,3 @@ ef_shrub_client_get_state(const struct ef_shrub_client* client)
9396
}
9497

9598
#endif
96-

‎src/include/etherfabric/internal/shrub_shared.h‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@
1919
#define __CI_CIUL_SHRUB_SHARED_H__
2020

2121
/* Identifier for a buffer, an index into the shared buffer memory.
22-
* The MSB for the id corresponds to the sentinel for the buffer. */
23-
typedef uint32_t ef_shrub_buffer_id;
22+
* Format (64-bit):
23+
* Bits [0:30] - buffer index (31 bits, supports up to 2^31 buffers)
24+
* Bit [31] - sentinel (1 bit)
25+
* Bits [32:63] - sbseq (32 bits, superbuf sequence number)
26+
*/
27+
typedef uint64_t ef_shrub_buffer_id;
2428

2529
/* The index of a buffer id */
2630
static inline uint32_t ef_shrub_buffer_index(ef_shrub_buffer_id id)
@@ -31,7 +35,13 @@ static inline uint32_t ef_shrub_buffer_index(ef_shrub_buffer_id id)
3135
/* The sentinel value of a buffer id */
3236
static inline uint32_t ef_shrub_buffer_sentinel(ef_shrub_buffer_id id)
3337
{
34-
return id >> 31;
38+
return (id >> 31) & 1;
39+
}
40+
41+
/* The sbseq value of a buffer id */
42+
static inline uint32_t ef_shrub_buffer_sbseq(ef_shrub_buffer_id id)
43+
{
44+
return id >> 32;
3545
}
3646

3747
/* Protocol version, to check compatibility between client and server */
@@ -183,4 +193,3 @@ struct ef_shrub_controller_request {
183193
};
184194

185195
#endif
186-

‎src/lib/ciul/efct_ubufs.c‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,19 +164,21 @@ static void post_buffers(ef_vi* vi, int ix)
164164
EF10CT_STATS_INC(vi, ix, post_fifo_full);
165165
}
166166

167-
static int efct_ubufs_next_shared(ef_vi* vi, int ix, bool* sentinel, unsigned* sbseq)
167+
static int efct_ubufs_next_shared(ef_vi* vi, int ix, bool* sentinel,
168+
unsigned* sbseq)
168169
{
169170
struct efct_ubufs_rxq* rxq = &get_ubufs(vi)->q[ix];
170-
ef_vi_efct_rxq_state* state = &vi->ep_state->rxq.efct_state[ix];
171+
uint32_t buffer_index;
172+
uint32_t shrub_sbseq;
171173

172-
ef_shrub_buffer_idid;
173-
intrc=ef_shrub_client_acquire_buffer(&rxq->shrub_client, &id, sentinel);
174+
intrc=ef_shrub_client_acquire_buffer(&rxq->shrub_client, &buffer_index,
175+
sentinel, &shrub_sbseq);
174176
if ( rc < 0 ) {
175177
EF10CT_STATS_INC(vi, ix, acquire_failures);
176178
return rc;
177179
}
178-
*sbseq = state->sbseq++;
179-
return id;
180+
*sbseq = shrub_sbseq;
181+
return buffer_index;
180182
}
181183

182184
static int efct_ubufs_next_local(ef_vi* vi, int ix, bool* sentinel, unsigned* sbseq)

‎src/lib/ciul/shrub_client.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ int ef_shrub_client_refresh_mappings(const struct ef_shrub_client* client,
185185

186186
int ef_shrub_client_acquire_buffer(struct ef_shrub_client* client,
187187
uint32_t* buffer_id,
188-
bool* sentinel)
188+
bool* sentinel,
189+
uint32_t* sbseq)
189190
{
190191
struct ef_shrub_client_state* state = get_state(client);
191192
int i = state->server_fifo_index;
@@ -198,6 +199,7 @@ int ef_shrub_client_acquire_buffer(struct ef_shrub_client* client,
198199

199200
*buffer_id = ef_shrub_buffer_index(id);
200201
*sentinel = ef_shrub_buffer_sentinel(id);
202+
*sbseq = ef_shrub_buffer_sbseq(id);
201203
return 0;
202204
}
203205

‎src/lib/ciul/shrub_queue.c‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@ struct ef_shrub_queue_buffer
1515
int fifo_index; /* Valid if ref_count is non-zero */
1616
};
1717

18-
/* Make a munged id value suitable for writing into the outgoing fifo */
19-
static ef_shrub_buffer_id make_buffer_id(int index, bool sentinel)
18+
/* Make a munged id value suitable for writing into the outgoing fifo
19+
* Format: [sbseq:32][sentinel:1][index:31]
20+
*/
21+
static ef_shrub_buffer_id make_buffer_id(int index, bool sentinel,
22+
uint32_t sbseq)
2023
{
2124
EF_VI_ASSERT(index >= 0);
22-
return (sentinel << 31) | index;
25+
return ((uint64_t)sbseq << 32) | ((uint64_t)sentinel << 31) | (uint64_t)index;
2326
}
2427

2528
static bool fifo_has_space(struct ef_shrub_queue* queue)
@@ -162,7 +165,7 @@ static void poll_fifo(struct ef_shrub_queue* queue)
162165

163166
int fifo_index = queue->fifo_index;
164167
assert(queue->fifo[fifo_index] == EF_SHRUB_INVALID_BUFFER);
165-
queue->fifo[fifo_index] = make_buffer_id(buffer_index, sentinel);
168+
queue->fifo[fifo_index] = make_buffer_id(buffer_index, sentinel, sbseq);
166169

167170
struct ef_shrub_queue_buffer* buffer = &queue->buffers[buffer_index];
168171
assert(buffer->ref_count == 0);

‎src/tests/unit/lib/ciul/shrub_queue.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ static struct ef_shrub_queue* queue;
2929
static int buffer_seq = 1234; // sequence number, initially arbitrary
3030
unsigned used_buffers = 0; // bitmask, initially unused
3131
unsigned buffer_sentinels = 0xaaaaaaaa; // bitmask, initially arbitrary
32+
static uint32_t buffer_sbseqs[32]; // Track sbseq for each buffer
3233

3334
static int buffer_sentinel(int index)
3435
{
@@ -37,7 +38,8 @@ static int buffer_sentinel(int index)
3738

3839
static ef_shrub_buffer_id buffer_id(int index)
3940
{
40-
return index | (buffer_sentinel(index) << 31);
41+
/* Use the actual sbseq that was assigned to this buffer */
42+
return ((uint64_t)buffer_sbseqs[index] << 32) | ((uint64_t)buffer_sentinel(index) << 31) | (uint64_t)index;
4143
}
4244

4345
int ef_shrub_server_memfd_create(const char* name, size_t size, bool huge)
@@ -103,6 +105,7 @@ static int mock_next(struct ef_vi* vi_, int qix_, bool* sentinel, unsigned* sbse
103105
buffer_sentinels ^= bit;
104106
*sentinel = buffer_sentinel(index);
105107
*sbseq = buffer_seq++;
108+
buffer_sbseqs[index] = *sbseq;
106109
return index;
107110
}
108111
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /