Skip to content

Commit 7df8931

Browse files
committed
ON-15146: Enable ZF_ATTR shrub_controller_id for enabling tcpdirect stacks to work with a given shrub_controller
1 parent 1f1fb5b commit 7df8931

File tree

4 files changed

+47
-2
lines changed

4 files changed

+47
-2
lines changed

src/include/zf_internal/attr_tmpl.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,13 @@ ZF_ATTR(int, phys_address_mode, stable, 0, NULL,
346346
"\n"
347347
"0 - Don't enable physical addressing mode. User space sees virtual addresses \n"
348348
" which are translated by hardware or in the kernel.")
349+
350+
ZF_ATTR(int, shrub_controller_id, stable, -1, NULL,
351+
"zf_vi",
352+
353+
"Enable shrub controller on this VI. This is required to enable zf_stacks \n"
354+
"to attach to a given shared controller on given x4 platforms. \n")
355+
349356
/**********************************************************************
350357
* zf_pool attributes.
351358
*/

src/include/zf_internal/private/zf_stack_def.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ struct zf_stack_impl {
286286
int sti_udp_ttl;
287287
int sti_rx_datapath;
288288
int sti_phys_address_mode;
289+
int sti_shrub_controller_id;
289290
uint64_t sti_log_level;
290291

291292
int n_alts; /* Number of alternatives actually allocated to this VI */

src/lib/zf/private/stack_alloc.c

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,21 @@ static int zf_stack_init_phys_address_mode(struct zf_stack_impl* sti,
319319
return 0;
320320
}
321321

322+
static int zf_stack_init_shrub_controller(struct zf_stack_impl* sti,
323+
struct zf_attr* attr,
324+
int* shrub_controller_id)
325+
{
326+
zf_stack* st = &sti->st;
327+
328+
if ( attr->shrub_controller_id < -1 || attr->shrub_controller_id > 9999 ) {
329+
zf_log_stack_err(st, "Bad shrub_controller_id; value must be -1 or in range 0 to 9999 \n");
330+
return -EINVAL;
331+
}
332+
333+
*shrub_controller_id = attr->shrub_controller_id;
334+
return 0;
335+
}
336+
322337
static int zf_stack_init_ctpio_stack_config(struct zf_stack_impl* sti,
323338
struct zf_attr* attr,
324339
int* ctpio_mode)
@@ -572,14 +587,16 @@ int zf_stack_init_nic_resources(struct zf_stack_impl* sti,
572587
struct zf_attr* attr, int nicno,
573588
int ifindex, zf_if_info* if_cplane_info,
574589
unsigned vi_flags, int ctpio_mode,
575-
int rx_datapath, bool phys_address_mode)
590+
int rx_datapath, bool phys_address_mode,
591+
int shrub_controller_id)
576592
{
577593
zf_stack* st = &sti->st;
578594
struct zf_stack_nic* st_nic = &st->nic[nicno];
579595
struct zf_stack_res_nic* sti_nic = &sti->nic[nicno];
580596
ef_pd_flags pd_flags = EF_PD_DEFAULT;
581597
int rc;
582598
unsigned long capability_val;
599+
char shrub_controller_char[5];
583600

584601
/* Open driver. */
585602
rc = ef_driver_open(&sti_nic->dh);
@@ -606,6 +623,18 @@ int zf_stack_init_nic_resources(struct zf_stack_impl* sti,
606623
pd_flags = (ef_pd_flags)(pd_flags | EF_PD_EXPRESS);
607624
}
608625

626+
rc = snprintf(shrub_controller_char, sizeof(shrub_controller_id), "%d", shrub_controller_id);
627+
if ( rc < 0 || rc >= (int)sizeof(shrub_controller_char) ) {
628+
zf_log_stack_err(st, "Failed to format shrub_controller_id\n");
629+
return -EINVAL;
630+
}
631+
632+
rc = setenv("EF_SHRUB_CONTROLLER", shrub_controller_char , 1);
633+
if ( rc != 0 && shrub_controller_id != -1 ) {
634+
zf_log_stack_err(st, "Failed to set EF_SHRUB_CONTROLLER environment variable\n");
635+
return -EINVAL;
636+
}
637+
609638
if ( phys_address_mode ) {
610639
rc = ef_vi_capabilities_get_from_pd_flags(
611640
sti_nic->dh, ifindex, (ef_pd_flags)(pd_flags | EF_PD_PHYS_MODE),
@@ -867,6 +896,11 @@ int zf_stack_alloc(struct zf_attr* attr, struct zf_stack** stack_out)
867896
rc = zf_stack_init_datapath(sti, attr, &rx_datapath);
868897
if( rc < 0 )
869898
goto fail2;
899+
900+
int shrub_controller_id;
901+
rc = zf_stack_init_shrub_controller(sti, attr, &shrub_controller_id);
902+
if( rc < 0 )
903+
goto fail2;
870904

871905
bool phys_address_mode;
872906
rc = zf_stack_init_phys_address_mode(sti, attr, &phys_address_mode);
@@ -905,6 +939,7 @@ int zf_stack_alloc(struct zf_attr* attr, struct zf_stack** stack_out)
905939
sti->sti_log_level = attr->log_level;
906940
sti->sti_rx_datapath = rx_datapath;
907941
sti->sti_phys_address_mode = phys_address_mode;
942+
sti->sti_shrub_controller_id = shrub_controller_id;
908943

909944
strncpy(sti->sti_ctpio_mode, attr->ctpio_mode, 8);
910945
if( st->encap_type & EF_CP_ENCAP_F_VLAN )
@@ -958,7 +993,8 @@ int zf_stack_alloc(struct zf_attr* attr, struct zf_stack** stack_out)
958993

959994
rc = zf_stack_init_nic_resources(sti, attr, nicno, hwport_ifindex,
960995
&hwport_cplane_info, vi_flags,
961-
ctpio_mode, rx_datapath, phys_address_mode);
996+
ctpio_mode, rx_datapath, phys_address_mode,
997+
shrub_controller_id);
962998
if( rc < 0 )
963999
goto fail3;
9641000
}

src/lib/zf/zf_stackdump.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ void dump_attributes(SkewPointer<zf_stack_impl> stimpl)
4848
? "enterprise"
4949
: "express"));
5050
zf_dump("phys_address_mode=%d\n", stimpl->sti_phys_address_mode);
51+
zf_dump("shrub_controller_id=%d\n", stimpl->sti_shrub_controller_id);
5152
zf_dump("pio=%d\n", stimpl->sti_pio);
5253
zf_dump("reactor_spin_count=%d\n", stimpl->sti_reactor_spin_count);
5354
zf_dump("tcp_timewait_ms=%d\n", stimpl->sti_tcp_timewait_ms);

0 commit comments

Comments
 (0)