diff options
author | Andy Grover <agrover@redhat.com> | 2016-10-03 10:54:33 -0700 |
---|---|---|
committer | Andy Grover <agrover@redhat.com> | 2016-10-03 10:54:33 -0700 |
commit | e04d87b5f8e5c2252e18dab7a8778ee03a1bf171 (patch) | |
tree | c544ff56d69fc5f0545ec14659ad8831c030d839 | |
parent | cb7f5ee9c011a20ddef976cd803b964e0bfb940e (diff) | |
download | rtslib-fb-e04d87b5f8e5c2252e18dab7a8778ee03a1bf171.tar.gz |
Implement support for cxgbit offload
Just like the 'iser' value within np/, save and restore the 'cxgbit' value.
However, the property is called 'offload'. This will let us handle other
offloads with the same property in the future if and when they are
supported.
Signed-off-by: Andy Grover <agrover@redhat.com>
-rw-r--r-- | doc/saveconfig.json.5 | 2 | ||||
-rw-r--r-- | rtslib/target.py | 22 |
2 files changed, 24 insertions, 0 deletions
diff --git a/doc/saveconfig.json.5 b/doc/saveconfig.json.5 index cc4513e..42c6317 100644 --- a/doc/saveconfig.json.5 +++ b/doc/saveconfig.json.5 @@ -195,6 +195,8 @@ values are (number). .I iser (boolean) is an optional value to enable iSER. +.I offload +(boolean) is an optional value to enable hardware offload. .SS node_acls This contains information about explicit initiator LUN mappings. diff --git a/rtslib/target.py b/rtslib/target.py index db44ebc..c2836db 100644 --- a/rtslib/target.py +++ b/rtslib/target.py @@ -728,10 +728,27 @@ class NetworkPortal(CFSNode): if os.path.isfile(path): raise RTSLibError("Cannot change iser") + def _get_offload(self): + try: + # only offload at the moment is cxgbit + return bool(int(fread("%s/cxgbit" % self.path))) + except IOError: + return False + + def _set_offload(self, boolean): + path = "%s/cxgbit" % self.path + try: + fwrite(path, str(int(boolean))) + except IOError: + # b/w compat: don't complain if cxgbit entry is missing + if os.path.isfile(path): + raise RTSLibError("Cannot change offload") + # NetworkPortal public stuff def delete(self): self.iser = False + self.offload = False super(NetworkPortal, self).delete() parent_tpg = property(_get_parent_tpg, @@ -743,6 +760,9 @@ class NetworkPortal(CFSNode): iser = property(_get_iser, _set_iser, doc="Get or set a boolean value representing if this " \ + "NetworkPortal supports iSER.") + offload = property(_get_offload, _set_offload, + doc="Get or set a boolean value representing if this " \ + + "NetworkPortal supports offload.") @classmethod def setup(cls, tpg_obj, p, err_func): @@ -756,6 +776,7 @@ class NetworkPortal(CFSNode): try: np = cls(tpg_obj, p['ip_address'], p['port']) np.iser = p.get('iser', False) + np.offload = p.get('offload', False) except (RTSLibError, KeyError) as e: err_func("Creating NetworkPortal object %s:%s failed: %s" % (p['ip_address'], p['port'], e)) @@ -765,6 +786,7 @@ class NetworkPortal(CFSNode): d['port'] = self.port d['ip_address'] = self.ip_address d['iser'] = self.iser + d['offload'] = self.offload return d |