Skip to content

Commit 05a7ce9

Browse files
committed
Merge fixups.
1 parent 4e0570f commit 05a7ce9

File tree

3 files changed

+17
-32
lines changed

3 files changed

+17
-32
lines changed

xde/src/mac/mod.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use alloc::string::String;
1616
use alloc::string::ToString;
1717
use alloc::sync::Arc;
1818
use bitflags::bitflags;
19+
use ingot::ip::IpProtocol;
1920
use core::ffi::CStr;
2021
use core::fmt;
2122
use core::mem::MaybeUninit;
@@ -616,7 +617,7 @@ impl OffloadInfo {
616617
pub struct MacFlowDesc {
617618
mask: flow_mask_t,
618619
ip_ver: Option<u8>,
619-
proto: Option<opte_core::ip4::Protocol>,
620+
proto: Option<IpProtocol>,
620621
local_port: Option<u16>,
621622
}
622623

@@ -647,7 +648,7 @@ impl MacFlowDesc {
647648
self
648649
}
649650

650-
pub fn set_proto(&mut self, proto: opte_core::ip4::Protocol) -> &mut Self {
651+
pub fn set_proto(&mut self, proto: IpProtocol) -> &mut Self {
651652
self.mask |= FLOW_IP_PROTOCOL;
652653
self.proto = Some(proto);
653654
self
@@ -663,18 +664,18 @@ impl MacFlowDesc {
663664
flow_desc_t::from(self.clone())
664665
}
665666

666-
pub fn new_flow<'a>(
667+
pub fn new_flow<'a, P>(
667668
&'a self,
668669
flow_name: &'a str,
669670
link_id: LinkId,
670-
) -> Result<MacFlow, FlowCreateError> {
671+
) -> Result<MacFlow<P>, FlowCreateError> {
671672
let name = CString::new(flow_name)
672673
.map_err(|_| FlowCreateError::InvalidFlowName(flow_name))?;
673674
let desc = self.to_desc();
674675

675676
match unsafe {
676677
mac_link_flow_add(
677-
link_id.0,
678+
link_id.into(),
678679
name.as_ptr(),
679680
&desc,
680681
&MAC_RESOURCE_PROPS_DEF,
@@ -686,7 +687,7 @@ impl MacFlowDesc {
686687

687688
let mut flent = ptr::null_mut();
688689
match unsafe { mac_flow_lookup_byname(name.as_ptr(), &mut flent) } {
689-
0 => Ok(MacFlow { name, flent, cb_mch: None }),
690+
0 => Ok(MacFlow { name, flent, parent: None }),
690691
err => Err(FlowCreateError::CreateFailed(flow_name, err)),
691692
}
692693
}
@@ -700,7 +701,7 @@ impl From<MacFlowDesc> for flow_desc_t {
700701
// The mac flow subsystem uses 0 as sentinel to indicate no
701702
// filtering on protocol.
702703
let fd_protocol = match mf.proto {
703-
Some(p) => p as u8,
704+
Some(p) => p.0,
704705
None => 0,
705706
};
706707

@@ -773,7 +774,6 @@ impl<P> MacFlow<P> {
773774
new_fn: mac_rx_fn,
774775
parent: Arc<P>,
775776
) {
776-
let mch = cb_mch.clone();
777777
let parent = Arc::into_raw(parent);
778778
let arg = parent as *mut c_void;
779779

@@ -791,12 +791,12 @@ impl<P> MacFlow<P> {
791791
// flow_cb_pre_srs(self.flent, new_fn);
792792
flow_cb_post_srs(self.flent, new_fn, arg);
793793
}
794-
self.cb_mch = Some(mch);
794+
self.parent = Some(parent);
795795
}
796796
}
797797

798798
/// Insert a flow callback which replaces `mac_rx_srs_subflow_process`.
799-
#[no_mangle]
799+
#[unsafe(no_mangle)]
800800
pub unsafe fn flow_cb_pre_srs(flent: *mut flow_entry_t, new_fn: mac_rx_fn) {
801801
// TODO: locks, negative handling, ...
802802
(*flent).fe_cb_fn = new_fn;
@@ -806,7 +806,7 @@ pub unsafe fn flow_cb_pre_srs(flent: *mut flow_entry_t, new_fn: mac_rx_fn) {
806806
///
807807
/// This will usually replace `mac_rx_deliver`, which will call into the mac_rx
808808
/// callback on the *parent device* (i.e., i_dls_link_rx).
809-
#[no_mangle]
809+
#[unsafe(no_mangle)]
810810
pub unsafe fn flow_cb_post_srs(
811811
flent: *mut flow_entry_t,
812812
new_fn: mac_rx_fn,
@@ -834,14 +834,14 @@ unsafe fn flow_user_refrele(flent: *mut flow_entry_t) {
834834
mutex_exit(&mut (*flent).fe_lock);
835835
}
836836

837-
impl Drop for MacFlow {
837+
impl<P> Drop for MacFlow<P> {
838838
fn drop(&mut self) {
839839
unsafe {
840840
// TODO: need to reimplement FLOW_USER_REFRELE in here...
841841
flow_user_refrele(self.flent);
842842
mac_link_flow_remove(self.name.as_ptr());
843843
if let Some(parent) = self.parent {
844-
Arc::from_raw(self.parent); // dropped immediately
844+
Arc::from_raw(parent); // dropped immediately
845845
}
846846
}
847847
}

xde/src/mac/sys.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use crate::ip::timeout_id_t;
1717
use illumos_sys_hdrs::boolean_t;
1818
use illumos_sys_hdrs::c_char;
1919
use illumos_sys_hdrs::c_int;
20-
use illumos_sys_hdrs::c_uchar;
2120
use illumos_sys_hdrs::c_short;
2221
use illumos_sys_hdrs::c_uchar;
2322
use illumos_sys_hdrs::c_uint;
@@ -875,9 +874,6 @@ pub enum mac_dhcpcid_form_t {
875874
CIDFORM_STR,
876875
}
877876

878-
pub const IP_NO_ADDR: in6_addr_t =
879-
in6_addr_t { _S6_un: in6_addr__bindgen_ty_1 { _S6_u16: [0u16; 8] } };
880-
881877
// typedef mac_resource_handle_t (*mac_resource_add_t)(void *, mac_resource_t *);
882878
pub type mac_resource_handle_t = *mut c_void;
883879

xde/src/xde.rs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ pub struct xde_underlay_port {
241241
pub mac: [u8; 6],
242242

243243
/// Handles to created MacFlow instances.
244-
flows: Vec<MacFlow>,
244+
flows: Vec<MacFlow<DlsStream>>,
245245

246246
/// The MTU of this link.
247247
pub mtu: u32,
@@ -967,8 +967,8 @@ fn clear_xde_underlay() -> Result<NoResp, OpteError> {
967967
// `DldStream`. We explicitly drop them in order here to ensure
968968
// there are no outstanding refs.
969969

970-
// 1. Remove promisc callback.
971-
drop(u.mph);
970+
// 1. Remove flow callback.
971+
drop(u.flows);
972972

973973
// Although `xde_rx` can be called into without any running ports
974974
// via the promisc handle, illumos guarantees that this callback won't
@@ -1091,7 +1091,6 @@ unsafe extern "C" fn xde_attach(
10911091
ddi_report_dev(xde_dip);
10921092
}
10931093

1094-
mac::mac_rx_set(state.u2.mch, xde_rx, ptr::null_mut());
10951094
DDI_SUCCESS
10961095
}
10971096

@@ -1128,7 +1127,7 @@ fn create_underlay_port(
11281127
let mut flow_desc = mac::MacFlowDesc::new();
11291128
flow_desc
11301129
// .set_ipver(6)
1131-
.set_proto(opte::api::ip::Protocol::UDP)
1130+
.set_proto(IpProtocol::UDP)
11321131
.set_local_port(opte::engine::geneve::GENEVE_PORT)
11331132
.to_desc();
11341133

@@ -1158,16 +1157,6 @@ fn create_underlay_port(
11581157
},
11591158
)?;
11601159

1161-
// Get a mac client handle as well.
1162-
//
1163-
let oflags = MacOpenFlags::NO_UNICAST_ADDR; //MULTI_PRIMARY;// MacOpenFlags::NONE;
1164-
let mch = MacClientHandle::open(&mh, Some(mc_name), oflags, 0)
1165-
.map(Arc::new)
1166-
.map_err(|e| OpteError::System {
1167-
errno: EFAULT,
1168-
msg: format!("mac_client_open failed for {link_name}: {e}"),
1169-
})?;
1170-
11711160
// Grab mac handle for underlying link, to retrieve its MAC address.
11721161
let mh = MacHandle::open_by_link_name(&link_name).map(Arc::new).map_err(
11731162
|e| OpteError::System {

0 commit comments

Comments
 (0)