nvme

package
v0.1.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 29, 2025 License: Apache-2.0 Imports: 31 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ResourceBlockId = "Rabbit"

	// TODO: The ALL_CAPS name in nvme package should be renamed to a valid Go name
	CommonNamespaceIdentifier = nvme.COMMON_NAMESPACE_IDENTIFIER

	// Physical Function controller index
	PhysicalFunctionControllerIndex = 0
)
View Source
const (
	DefaultFeatureType = 1
)
View Source
const (
	DefaultStoragePoolId = "0"
)

Variables

This section is empty.

Functions

func BindFlags

func BindFlags(fs *flag.FlagSet)

func CleanupVolumes

func CleanupVolumes(providingVolumes []ProvidingVolume)

CleanupVolumes - remove all volumes other than the list of providingVolumes

func Close

func Close() error

func ConvertRelativePortIndexToControllerIndex

func ConvertRelativePortIndexToControllerIndex(index uint32) (uint16, error)

func EnumerateStorage

func EnumerateStorage(storageHandlerFunc func(odataId string, capacityBytes uint64, unallocatedBytes uint64)) error

func GetWearLevelAsPercentageUsed added in v0.1.10

func GetWearLevelAsPercentageUsed(dev NvmeDeviceApi) (uint8, error)

GetWearLevelAsPercentageUsed returns the PercentageUsed field from the SMART log page.

func Initialize

func Initialize(log ec.Logger, ctrl NvmeController) error

Initialize the controller

func NewDefaultApiRouter

func NewDefaultApiRouter(s Api, c NvmeController) ec.Router

NewDefaultApiRouter -

func StartNVMeMonitor added in v0.1.10

func StartNVMeMonitor(log ec.Logger)

StartNVMeMonitor starts a background goroutine that periodically queries all NVMe devices for their SMART log.

Types

type Api

type Api interface {
	RedfishV1StorageGet(w http.ResponseWriter, r *http.Request)
	RedfishV1StorageStorageIdGet(w http.ResponseWriter, r *http.Request)

	RedfishV1StorageStorageIdStoragePoolsGet(w http.ResponseWriter, r *http.Request)
	RedfishV1StorageStorageIdStoragePoolsStoragePoolIdGet(w http.ResponseWriter, r *http.Request)

	RedfishV1StorageStorageIdControllersGet(w http.ResponseWriter, r *http.Request)
	RedfishV1StorageStorageIdControllersControllerIdGet(w http.ResponseWriter, r *http.Request)

	RedfishV1StorageStorageIdVolumesGet(w http.ResponseWriter, r *http.Request)
	RedfishV1StorageStorageIdVolumesPost(w http.ResponseWriter, r *http.Request)

	RedfishV1StorageStorageIdVolumesVolumeIdGet(w http.ResponseWriter, r *http.Request)
	RedfishV1StorageStorageIdVolumesVolumeIdDelete(w http.ResponseWriter, r *http.Request)
}

Api - defines an interface for Near-Node Flash related methods

func NewDefaultApiService

func NewDefaultApiService() Api

NewDefaultApiService -

type ConfigFile

type ConfigFile struct {
	Version  string
	Metadata struct {
		Name string
	}
	Storage StorageConfig
}

type ControllerConfig

type ControllerConfig struct {
	Functions uint32
	Resources uint32
}

type DefaultApiRouter

type DefaultApiRouter struct {
	// contains filtered or unexported fields
}

DefaultApiRouter -

func (*DefaultApiRouter) Close

func (r *DefaultApiRouter) Close() error

Close -

func (*DefaultApiRouter) Init

func (r *DefaultApiRouter) Init(log ec.Logger) error

Init -

func (*DefaultApiRouter) Name

func (*DefaultApiRouter) Name() string

Name -

func (*DefaultApiRouter) Routes

func (r *DefaultApiRouter) Routes() ec.Routes

Routes -

func (*DefaultApiRouter) Start

func (r *DefaultApiRouter) Start() error

Start -

type DefaultApiService

type DefaultApiService struct {
	// contains filtered or unexported fields
}

DefaultApiService -

func (*DefaultApiService) RedfishV1StorageGet

func (s *DefaultApiService) RedfishV1StorageGet(w http.ResponseWriter, r *http.Request)

RedfishV1StorageGet

func (*DefaultApiService) RedfishV1StorageStorageIdControllersControllerIdGet

func (s *DefaultApiService) RedfishV1StorageStorageIdControllersControllerIdGet(w http.ResponseWriter, r *http.Request)

RedfishV1StorageStorageIdControllersControllerIdGet

func (*DefaultApiService) RedfishV1StorageStorageIdControllersGet

func (s *DefaultApiService) RedfishV1StorageStorageIdControllersGet(w http.ResponseWriter, r *http.Request)

RedfishV1StorageStorageIdControllersGet

func (*DefaultApiService) RedfishV1StorageStorageIdGet

func (s *DefaultApiService) RedfishV1StorageStorageIdGet(w http.ResponseWriter, r *http.Request)

RedfishV1StorageStorageIdGet

func (*DefaultApiService) RedfishV1StorageStorageIdStoragePoolsGet

func (s *DefaultApiService) RedfishV1StorageStorageIdStoragePoolsGet(w http.ResponseWriter, r *http.Request)

RedfishV1StorageStorageIdStoragePoolsGet

func (*DefaultApiService) RedfishV1StorageStorageIdStoragePoolsStoragePoolIdGet

func (s *DefaultApiService) RedfishV1StorageStorageIdStoragePoolsStoragePoolIdGet(w http.ResponseWriter, r *http.Request)

RedfishV1StorageStorageIdStoragePoolsStoragePoolIdGet

func (*DefaultApiService) RedfishV1StorageStorageIdVolumesGet

func (s *DefaultApiService) RedfishV1StorageStorageIdVolumesGet(w http.ResponseWriter, r *http.Request)

RedfishV1StorageStorageIdVolumesGet

func (*DefaultApiService) RedfishV1StorageStorageIdVolumesPost

func (s *DefaultApiService) RedfishV1StorageStorageIdVolumesPost(w http.ResponseWriter, r *http.Request)

RedfishV1StorageStorageIdVolumesPost

func (*DefaultApiService) RedfishV1StorageStorageIdVolumesVolumeIdDelete

func (s *DefaultApiService) RedfishV1StorageStorageIdVolumesVolumeIdDelete(w http.ResponseWriter, r *http.Request)

RedfishV1StorageStorageIdVolumesVolumeIdDelete -

func (*DefaultApiService) RedfishV1StorageStorageIdVolumesVolumeIdGet

func (s *DefaultApiService) RedfishV1StorageStorageIdVolumesVolumeIdGet(w http.ResponseWriter, r *http.Request)

RedfishV1StorageStorageIdVolumesVolumeIdGet -

type DirectNvmeController

type DirectNvmeController struct {
	// contains filtered or unexported fields
}

func (*DirectNvmeController) NewNvmeDeviceController

func (c *DirectNvmeController) NewNvmeDeviceController() NvmeDeviceController

type DirectNvmeDeviceController

type DirectNvmeDeviceController struct {
	// contains filtered or unexported fields
}

func (*DirectNvmeDeviceController) Close

func (c *DirectNvmeDeviceController) Close() error

func (*DirectNvmeDeviceController) Initialize

func (c *DirectNvmeDeviceController) Initialize() error

func (*DirectNvmeDeviceController) NewNvmeDevice

func (c *DirectNvmeDeviceController) NewNvmeDevice(fabricId string, switchId string, portId string) (NvmeDeviceApi, error)

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager -

func (*Manager) EventHandler

func (m *Manager) EventHandler(e event.Event) error

func (*Manager) Get

Get -

func (*Manager) GetVolumes

func (m *Manager) GetVolumes(controllerId string) ([]string, error)

GetVolumes -

func (*Manager) StorageIdControllersControllerIdGet

func (mgr *Manager) StorageIdControllersControllerIdGet(storageId, controllerId string, model *sf.StorageControllerV100StorageController) error

StorageIdControllersControllerIdGet -

func (*Manager) StorageIdControllersGet

func (mgr *Manager) StorageIdControllersGet(storageId string, model *sf.StorageControllerCollectionStorageControllerCollection) error

StorageIdControllersGet -

func (*Manager) StorageIdGet

func (mgr *Manager) StorageIdGet(storageId string, model *sf.StorageV190Storage) error

StorageIdGet -

func (*Manager) StorageIdStoragePoolsGet

func (mgr *Manager) StorageIdStoragePoolsGet(storageId string, model *sf.StoragePoolCollectionStoragePoolCollection) error

StorageIdStoragePoolsGet -

func (*Manager) StorageIdStoragePoolsStoragePoolIdGet

func (mgr *Manager) StorageIdStoragePoolsStoragePoolIdGet(storageId, storagePoolId string, model *sf.StoragePoolV150StoragePool) error

StorageIdStoragePoolsStoragePoolIdGet -

func (*Manager) StorageIdVolumeIdDelete

func (mgr *Manager) StorageIdVolumeIdDelete(storageId, volumeId string) error

StorageIdVolumeIdDelete -

func (*Manager) StorageIdVolumeIdGet

func (mgr *Manager) StorageIdVolumeIdGet(storageId, volumeId string, model *sf.VolumeV161Volume) error

StorageIdVolumeIdGet -

func (*Manager) StorageIdVolumesGet

func (mgr *Manager) StorageIdVolumesGet(storageId string, model *sf.VolumeCollectionVolumeCollection) error

StorageIdVolumesGet -

func (*Manager) StorageIdVolumesPost

func (mgr *Manager) StorageIdVolumesPost(storageId string, model *sf.VolumeV161Volume) error

StorageIdVolumesPost -

type MockNvmeController

type MockNvmeController struct {
	// contains filtered or unexported fields
}

func (MockNvmeController) NewNvmeDeviceController

func (ctrl MockNvmeController) NewNvmeDeviceController() NvmeDeviceController

type MockNvmeDeviceController

type MockNvmeDeviceController struct {
	// contains filtered or unexported fields
}

func (*MockNvmeDeviceController) Close

func (ctrl *MockNvmeDeviceController) Close() error

func (*MockNvmeDeviceController) Initialize

func (ctrl *MockNvmeDeviceController) Initialize() error

func (MockNvmeDeviceController) NewNvmeDevice

func (ctrl MockNvmeDeviceController) NewNvmeDevice(fabricId, switchId, portId string) (NvmeDeviceApi, error)

type MockNvmePersistenceManager

type MockNvmePersistenceManager struct {
	// contains filtered or unexported fields
}

type Monitor added in v0.1.10

type Monitor struct {
	Log        ec.Logger
	Interval   time.Duration
	GetDevices func() []*nvme.Device // Function to return all NVMe devices
}

Monitor periodically queries all NVMe devices for their SMART log and can be started as a background goroutine.

func NewMonitor added in v0.1.10

func NewMonitor(log ec.Logger, interval time.Duration) *Monitor

NewMonitor creates a new NVMe monitor with the given polling interval and device getter.

func (*Monitor) Run added in v0.1.10

func (m *Monitor) Run()

Run starts the monitor loop. It periodically calls GetSmartLog on all devices.

type NvmeController

type NvmeController interface {
	NewNvmeDeviceController() NvmeDeviceController
}

func NewCliNvmeController

func NewCliNvmeController() NvmeController

func NewDirectDeviceNvmeController

func NewDirectDeviceNvmeController(deviceRegexp string) NvmeController

func NewMockNvmeController

func NewMockNvmeController(persistence bool) NvmeController

func NewSwitchtecNvmeController

func NewSwitchtecNvmeController() NvmeController

type NvmeDeviceApi

type NvmeDeviceApi interface {
	IsDirectDevice() bool

	IdentifyController(controllerId uint16) (*nvme.IdCtrl, error)
	IdentifyNamespace(namespaceId nvme.NamespaceIdentifier) (*nvme.IdNs, error)

	ListSecondary() (*nvme.SecondaryControllerList, error)

	AssignControllerResources(
		controllerId uint16,
		resourceType SecondaryControllerResourceType,
		numResources uint32) error

	OnlineController(controllerId uint16) error

	ListNamespaces(controllerId uint16) ([]nvme.NamespaceIdentifier, error)
	ListAttachedControllers(namespaceId nvme.NamespaceIdentifier) ([]uint16, error)

	CreateNamespace(sizeInSectors uint64, sectorSizeIndex uint8) (nvme.NamespaceIdentifier, nvme.NamespaceGloballyUniqueIdentifier, error)
	DeleteNamespace(namespaceId nvme.NamespaceIdentifier) error

	FormatNamespace(namespaceID nvme.NamespaceIdentifier) error

	AttachNamespace(namespaceId nvme.NamespaceIdentifier, controllers []uint16) error
	DetachNamespace(namespaceId nvme.NamespaceIdentifier, controllers []uint16) error

	SetNamespaceFeature(namespaceId nvme.NamespaceIdentifier, data []byte) error
	GetNamespaceFeature(namespaceId nvme.NamespaceIdentifier) ([]byte, error)

	// GetSmartLog returns the raw SMART log page data
	GetSmartLog() (*nvme.SmartLog, error)
}

NvmeDeviceApi -

type NvmeDeviceController

type NvmeDeviceController interface {
	Initialize() error
	Close() error

	NewNvmeDevice(fabricId, switchId, portId string) (NvmeDeviceApi, error)
}

type ProvidingVolume

type ProvidingVolume struct {
	Storage  *Storage
	VolumeId string
}

ProvidingVolume - volume as part of a storage pool

type SecondaryControllerHandlerFunc

type SecondaryControllerHandlerFunc func(controllerId uint16, controllerOnline bool, virtualFunctionNumber uint16, numVQResourcesAssinged, numVIResourcesAssigned uint32) error

SecondaryControllerHandlerFunc -

type SecondaryControllerResourceType

type SecondaryControllerResourceType int

SecondaryControllerResourceType -

const (
	VQResourceType SecondaryControllerResourceType = iota
	VIResourceType
)

type SecondaryControllersInitFunc

type SecondaryControllersInitFunc func(count uint8)

SecondaryControllersInitFunc -

type Storage

type Storage struct {
	// contains filtered or unexported fields
}

Storage - Storage defines a generic storage device in the Redfish / Swordfish specification. In the NNF implementation

func GetStorage

func GetStorage() []*Storage

func (*Storage) FindVolume

func (s *Storage) FindVolume(id string) *Volume

func (*Storage) FindVolumeByNamespaceId

func (s *Storage) FindVolumeByNamespaceId(namespaceId nvme.NamespaceIdentifier) (*Volume, error)

func (*Storage) IsEnabled

func (s *Storage) IsEnabled() bool

func (*Storage) IsKioxiaDualPortConfiguration

func (s *Storage) IsKioxiaDualPortConfiguration() bool

func (*Storage) LinkDroppedEventHandler

func (s *Storage) LinkDroppedEventHandler() error

func (*Storage) LinkEstablishedEventHandler

func (s *Storage) LinkEstablishedEventHandler(switchId, portId string) error

func (*Storage) OdataId

func (s *Storage) OdataId() string

func (*Storage) OdataIdRef

func (s *Storage) OdataIdRef(ref string) sf.OdataV4IdRef

func (*Storage) Rescan added in v0.1.7

func (s *Storage) Rescan() error

func (*Storage) SerialNumber

func (s *Storage) SerialNumber() string

func (*Storage) Slot added in v0.1.7

func (s *Storage) Slot() int64

func (*Storage) UnallocatedBytes

func (s *Storage) UnallocatedBytes() uint64

type StorageApi

type StorageApi interface {
	Get(*sf.StorageCollectionStorageCollection) error
	StorageIdGet(string, *sf.StorageV190Storage) error

	StorageIdStoragePoolsGet(string, *sf.StoragePoolCollectionStoragePoolCollection) error
	StorageIdStoragePoolsStoragePoolIdGet(string, string, *sf.StoragePoolV150StoragePool) error

	StorageIdControllersGet(string, *sf.StorageControllerCollectionStorageControllerCollection) error
	StorageIdControllersControllerIdGet(string, string, *sf.StorageControllerV100StorageController) error

	StorageIdVolumesGet(string, *sf.VolumeCollectionVolumeCollection) error
	StorageIdVolumesPost(string, *sf.VolumeV161Volume) error

	StorageIdVolumeIdGet(string, string, *sf.VolumeV161Volume) error
	StorageIdVolumeIdDelete(string, string) error
}

func NewDefaultStorageService

func NewDefaultStorageService() StorageApi

type StorageConfig

type StorageConfig struct {
	Controller ControllerConfig
	Devices    []string `yaml:",flow"`
}

type StorageController

type StorageController struct {
	// contains filtered or unexported fields
}

StorageController -

type SwitchtecNvmeController

type SwitchtecNvmeController struct{}

func (SwitchtecNvmeController) NewNvmeDeviceController

func (SwitchtecNvmeController) NewNvmeDeviceController() NvmeDeviceController

type SwitchtecNvmeDeviceController

type SwitchtecNvmeDeviceController struct{}

func (SwitchtecNvmeDeviceController) Close

func (SwitchtecNvmeDeviceController) Initialize

func (SwitchtecNvmeDeviceController) Initialize() error

func (SwitchtecNvmeDeviceController) NewNvmeDevice

func (SwitchtecNvmeDeviceController) NewNvmeDevice(fabricId, switchId, portId string) (NvmeDeviceApi, error)

type Volume

type Volume struct {
	// contains filtered or unexported fields
}

Volumes -

func CreateVolume

func CreateVolume(s *Storage, capacityBytes uint64) (*Volume, error)

func (*Volume) AttachController

func (v *Volume) AttachController(controllerId uint16) error

func (*Volume) AttachControllerIfUnattached added in v0.1.7

func (v *Volume) AttachControllerIfUnattached(controllerIndex uint16) error

AttachControllerIfUnattached ensures that a specified controller is attached to the volume. If the controller is not already attached, it attempts to attach it.

Parameters:

  • controllerIndex: The index of the controller to check and attach if necessary.

Returns:

  • error: An error if the operation to list or attach controllers fails, otherwise nil.

This function logs detailed information about the operation, including the storage ID, volume ID, controller index, and controller ID. It also logs the list of currently attached controllers and whether a reattachment is performed.

func (*Volume) Delete

func (v *Volume) Delete() error

func (*Volume) DetachController

func (v *Volume) DetachController(controllerId uint16) error

func (*Volume) Format

func (v *Volume) Format() error

func (*Volume) GetCapacityBytes added in v0.1.2

func (v *Volume) GetCapacityBytes() uint64

func (*Volume) GetGloballyUniqueIdentifier

func (v *Volume) GetGloballyUniqueIdentifier() nvme.NamespaceGloballyUniqueIdentifier

func (*Volume) GetNamespaceId

func (v *Volume) GetNamespaceId() nvme.NamespaceIdentifier

func (*Volume) GetOdataId

func (v *Volume) GetOdataId() string

func (*Volume) Id

func (v *Volume) Id() string

Getters for common volume operations

func (*Volume) SetFeature

func (v *Volume) SetFeature(data []byte) error

func (*Volume) WaitFormatComplete

func (v *Volume) WaitFormatComplete() error

WaitFormatComplete waits for Format Completion by polling until the namespace Utilization reaches zero.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL