Skip to content

Commit

Permalink
Rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
palade committed Apr 23, 2024
1 parent 3eb2904 commit 9d35aad
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 13 deletions.
40 changes: 27 additions & 13 deletions ipu-plugin/pkg/ipuplugin/lifecycleservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,16 @@ type SSHHandler interface {
type SSHHandlerImpl struct{}

type FXPHandler interface {
configureFXP()
configureFXP(p4rtbin string) error
}

type FXPHandlerImpl struct{}

var fileSystemHandler FileSystemHandler
var networkHandler NetworkHandler
var executableHandler ExecutableHandler
var sshHandler SSHHandler
var fxpHandler FXPHandler

func initHandlers() {
if fileSystemHandler == nil {
Expand All @@ -128,6 +131,9 @@ func initHandlers() {
if sshHandler == nil {
sshHandler = &SSHHandlerImpl{}
}
if fxpHandler == nil {
fxpHandler = &FXPHandlerImpl{}
}
}

func isPF(iface string) (bool, error) {
Expand Down Expand Up @@ -482,6 +488,23 @@ func (e *ExecutableHandlerImpl) validate() bool {
return true
}

func (s *FXPHandlerImpl) configureFXP(p4rtbin string) error {
vfMacList, err := utils.GetVfMacList()

if err != nil {
return fmt.Errorf("unable to reach the IMC %v", err)
}

if len(vfMacList) == 0 {
return fmt.Errorf("no NFs initialized on the host")
}

p4rtclient.DeletePointToPointVFRules(p4rtbin, vfMacList)
p4rtclient.CreatePointToPointVFRules(p4rtbin, vfMacList)

return nil
}

func (s *LifeCycleServiceServer) Init(ctx context.Context, in *pb.InitRequest) (*pb.IpPort, error) {
initHandlers()

Expand All @@ -499,19 +522,10 @@ func (s *LifeCycleServiceServer) Init(ctx context.Context, in *pb.InitRequest) (
log.Info("not forcing state")
}

vfMacList, err := utils.GetVfMacList()

if err != nil {
return nil, status.Errorf(codes.Internal, "Unable to reach the IMC %v", err)
}

if len(vfMacList) == 0 {
return nil, status.Error(codes.Internal, "No NFs initialized on the host")
}

// Preconfigure the FXP with point-to-point rules between host VFs
p4rtclient.DeletePointToPointVFRules(s.p4rtbin, vfMacList)
p4rtclient.CreatePointToPointVFRules(s.p4rtbin, vfMacList)
if err := fxpHandler.configureFXP(s.p4rtbin); err != nil {
return nil, status.Errorf(codes.Internal, "Error when preconfiguring the FXP: %v", err)
}
}

if err := configureChannel(s.mode, s.daemonHostIp, s.daemonIpuIp); err != nil {
Expand Down
7 changes: 7 additions & 0 deletions ipu-plugin/pkg/ipuplugin/lifecycleservice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var _ = Describe("basic functionality", Serial, func() {
fileSystemHandler = &MockFileSystemHandlerImpl{}
networkHandler = &MockNetworkHandlerImpl{}
executableHandler = &MockExecutableHandlerImpl{}
fxpHandler = &MockFXPHandlerImpl{}

Describe("pf communication channel setup", Serial, func() {

Expand Down Expand Up @@ -256,3 +257,9 @@ type MockExecutableHandlerImpl struct{}
func (m *MockExecutableHandlerImpl) validate() bool {
return true
}

type MockFXPHandlerImpl struct{}

func (m *MockFXPHandlerImpl) configureFXP(p4rtbin string) error {
return nil
}

0 comments on commit 9d35aad

Please sign in to comment.