of1.2: add OXM_OF_METADATA support

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
Simon Horman 2012-07-23 14:33:07 +09:00 committed by FUJITA Tomonori
parent 68bfa1f84d
commit a7eb8c4254

View File

@ -1427,6 +1427,7 @@ class Flow(object):
def __init__(self):
self.in_port = 0
self.in_phy_port = 0
self.metadata = 0
self.dl_dst = mac.DONTCARE
self.dl_src = mac.DONTCARE
self.dl_type = 0
@ -1464,6 +1465,7 @@ class Flow(object):
class FlowWildcards(object):
def __init__(self):
self.metadata_mask = 0
self.dl_dst_mask = 0
self.dl_src_mask = 0
self.vlan_vid_mask = 0
@ -1504,6 +1506,14 @@ class OFPMatch(object):
self.append_field(ofproto_v1_2.OXM_OF_IN_PHY_PORT,
self.flow.in_phy_port)
if self.wc.ft_test(ofproto_v1_2.OFPXMT_OFB_METADATA):
if self.wc.metadata_mask == UINT64_MAX:
header = ofproto_v1_2.OXM_OF_METADATA
else:
header = ofproto_v1_2.OXM_OF_METADATA_W
self.append_field(header, self.flow.metadata,
self.wc.metadata_mask)
if self.wc.ft_test(ofproto_v1_2.OFPXMT_OFB_ETH_DST):
if self.wc.dl_dst_mask:
header = ofproto_v1_2.OXM_OF_ETH_DST_W
@ -1706,6 +1716,15 @@ class OFPMatch(object):
self.wc.ft_set(ofproto_v1_2.OFPXMT_OFB_IN_PHY_PORT)
self.flow.in_phy_port = phy_port
def set_metadata(self, metadata):
self.wc.ft_set(ofproto_v1_2.OFPXMT_OFB_METADATA)
self.flow.metadata = metadata
def set_metadata_masked(self, metadata, mask):
self.wc.ft_set(ofproto_v1_2.OFPXMT_OFB_METADATA)
self.wc.metadata_mask = mask
self.flow.metadata = metadata & mask
def set_dl_dst(self, dl_dst):
self.wc.ft_set(ofproto_v1_2.OFPXMT_OFB_ETH_DST)
self.flow.dl_dst = dl_dst
@ -1983,6 +2002,17 @@ class MTInPort(OFPMatchField):
self.value = value
@OFPMatchField.register_field_header([ofproto_v1_2.OXM_OF_METADATA,
ofproto_v1_2.OXM_OF_METADATA_W])
class MTMetadata(OFPMatchField):
pack_str = '!Q'
def __init__(self, header, value, mask=None):
super(MTMetadata, self).__init__(header)
self.value = value
self.mask = mask
@OFPMatchField.register_field_header([ofproto_v1_2.OXM_OF_IN_PHY_PORT])
class MTInPhyPort(OFPMatchField):
pack_str = '!I'