@@ -161,7 +161,7 @@ func addReceiver(portId uint16, out low.Rings, inIndexNumber int32) {
161
161
par .port = low .GetPort (portId )
162
162
par .out = out
163
163
par .status = make ([]int32 , maxRecv , maxRecv )
164
- schedState .addFF ("receiver" , nil , recvRSS , nil , par , nil , receiveRSS , inIndexNumber , & par .stats )
164
+ schedState .addFF ("receiverPort" + string ( portId ) , nil , recvRSS , nil , par , nil , receiveRSS , inIndexNumber , & par .stats )
165
165
}
166
166
167
167
type receiveOSParameters struct {
@@ -256,18 +256,23 @@ func addFastGenerator(out low.Rings, generateFunction GenerateFunction,
256
256
}
257
257
258
258
type sendParameters struct {
259
- in low.Rings
260
- port uint16
261
- anyway bool
262
- stats common.RXTXStats
259
+ in low.Rings
260
+ port uint16
261
+ unrestrictedClones bool
262
+ stats common.RXTXStats
263
+ sendThreadIndex int
263
264
}
264
265
265
266
func addSender (port uint16 , in low.Rings , inIndexNumber int32 ) {
266
- par := new (sendParameters )
267
- par .port = port
268
- par .in = in
269
- par .anyway = schedState .anyway
270
- schedState .addFF ("sender" , nil , send , nil , par , nil , sendReceiveKNI , inIndexNumber , & par .stats )
267
+ for iii := 0 ; iii < sendCPUCoresPerPort ; iii ++ {
268
+ par := new (sendParameters )
269
+ par .port = port
270
+ par .in = in
271
+ par .unrestrictedClones = schedState .unrestrictedClones
272
+ par .sendThreadIndex = iii
273
+ schedState .addFF ("senderPort" + string (port )+ "Thread" + string (iii ),
274
+ nil , send , nil , par , nil , sendReceiveKNI , inIndexNumber , & par .stats )
275
+ }
271
276
}
272
277
273
278
type sendOSParameters struct {
@@ -468,6 +473,7 @@ var sizeMultiplier uint
468
473
var schedTime uint
469
474
var hwtxchecksum , hwrxpacketstimestamp , setSIGINTHandler bool
470
475
var maxRecv int
476
+ var sendCPUCoresPerPort , tXQueuesNumberPerPort int
471
477
472
478
type port struct {
473
479
wasRequested bool // has user requested any send/receive operations at this port
@@ -531,7 +537,7 @@ type Config struct {
531
537
// Limits parallel instances. 1 for one instance, 1000 for RSS count determine instances
532
538
MaxInIndex int32
533
539
// Scheduler should clone functions even if it can lead to reordering.
534
- // This option should be switch off for all high level reassembling like TCP or HTTP
540
+ // This option should be switched off for all high level reassembling like TCP or HTTP
535
541
RestrictedCloning bool
536
542
// If application uses EncapsulateHead or DecapsulateHead functions L2 pointers
537
543
// should be reinit every receving or generating a packet. This can be removed if
@@ -570,6 +576,19 @@ type Config struct {
570
576
// SystemStartScheduler waits for SIGINT notification and calls
571
577
// SystemStop after it. It is enabled by default.
572
578
NoSetSIGINTHandler bool
579
+ // Number of CPU cores to be occupied by Send routines. It is
580
+ // necessary to set TXQueuesNumberPerPort to a reasonably big
581
+ // number which can be divided by SendCPUCoresPerPort.
582
+ SendCPUCoresPerPort int
583
+ // Number of transmit queues to use on network card. By default it
584
+ // is minimum of NIC supported TX queues number and 2. If this
585
+ // value is specified and NIC doesn't support this number of TX
586
+ // queues, initialization fails.
587
+ TXQueuesNumberPerPort int
588
+ // Controls scheduler interval in milliseconds. Default value is
589
+ // 500. Lower values allow faster reaction to changing traffic but
590
+ // increase scheduling overhead.
591
+ SchedulerInterval uint
573
592
}
574
593
575
594
// SystemInit is initialization of system. This function should be always called before graph construction.
@@ -588,12 +607,26 @@ func SystemInit(args *Config) error {
588
607
cpus = common .GetDefaultCPUs (CPUCoresNumber )
589
608
}
590
609
610
+ tXQueuesNumberPerPort = args .TXQueuesNumberPerPort
611
+ if tXQueuesNumberPerPort == 0 {
612
+ tXQueuesNumberPerPort = 2
613
+ }
614
+
615
+ sendCPUCoresPerPort = args .SendCPUCoresPerPort
616
+ if sendCPUCoresPerPort == 0 {
617
+ sendCPUCoresPerPort = 1
618
+ if tXQueuesNumberPerPort % sendCPUCoresPerPort != 0 {
619
+ return common .WrapWithNFError (nil , "TXQueuesNumberPerPort should be divisible by SendCPUCoresPerPort" ,
620
+ common .BadArgument )
621
+ }
622
+ }
623
+
591
624
schedulerOff := args .DisableScheduler
592
625
schedulerOffRemove := args .PersistentClones
593
626
stopDedicatedCore := args .StopOnDedicatedCore
594
627
hwtxchecksum = args .HWTXChecksum
595
628
hwrxpacketstimestamp = args .HWRXPacketsTimestamp
596
- anyway := ! args .RestrictedCloning
629
+ unrestrictedClones := ! args .RestrictedCloning
597
630
598
631
mbufNumber := uint (8191 )
599
632
if args .MbufNumber != 0 {
@@ -610,7 +643,12 @@ func SystemInit(args *Config) error {
610
643
sizeMultiplier = args .RingSize
611
644
}
612
645
613
- schedTime = 500
646
+ if args .SchedulerInterval != 0 {
647
+ schedTime = args .SchedulerInterval
648
+ } else {
649
+ schedTime = 500
650
+ }
651
+
614
652
if args .ScaleTime != 0 {
615
653
schedTime = args .ScaleTime
616
654
}
@@ -702,7 +740,7 @@ func SystemInit(args *Config) error {
702
740
common .LogTitle (common .Initialization , "------------***------ Initializing scheduler -----***------------" )
703
741
StopRing := low .CreateRings (burstSize * sizeMultiplier , maxInIndex /* Maximum possible rings */ )
704
742
common .LogDebug (common .Initialization , "Scheduler can use cores:" , cpus )
705
- schedState = newScheduler (cpus , schedulerOff , schedulerOffRemove , stopDedicatedCore , StopRing , checkTime , debugTime , maxPacketsToClone , maxRecv , anyway )
743
+ schedState = newScheduler (cpus , schedulerOff , schedulerOffRemove , stopDedicatedCore , StopRing , checkTime , debugTime , maxPacketsToClone , maxRecv , unrestrictedClones )
706
744
707
745
// Set HW offloading flag in packet package
708
746
packet .SetHWTXChecksumFlag (hwtxchecksum )
@@ -737,7 +775,7 @@ func SystemInitPortsAndMemory() error {
737
775
for i := range createdPorts {
738
776
if createdPorts [i ].wasRequested {
739
777
if err := low .CreatePort (createdPorts [i ].port , createdPorts [i ].willReceive ,
740
- true , hwtxchecksum , hwrxpacketstimestamp , createdPorts [i ].InIndex ); err != nil {
778
+ true , hwtxchecksum , hwrxpacketstimestamp , createdPorts [i ].InIndex , tXQueuesNumberPerPort ); err != nil {
741
779
return err
742
780
}
743
781
}
@@ -1690,7 +1728,8 @@ func pcopy(parameters interface{}, inIndex []int32, stopper [2]chan int, report
1690
1728
1691
1729
func send (parameters interface {}, inIndex []int32 , flag * int32 , coreID int ) {
1692
1730
srp := parameters .(* sendParameters )
1693
- low .Send (srp .port , srp .in , srp .anyway , flag , coreID , & srp .stats )
1731
+ low .Send (srp .port , srp .in , srp .unrestrictedClones , flag , coreID , & srp .stats ,
1732
+ srp .sendThreadIndex , sendCPUCoresPerPort )
1694
1733
}
1695
1734
1696
1735
func sendOS (parameters interface {}, inIndex []int32 , flag * int32 , coreID int ) {
0 commit comments