1 // Copyright 2022 The Chromium OS Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 use base::iov_max; 6 use std::cmp::{max, min}; 7 get_seg_max(queue_size: u16) -> u328pub fn get_seg_max(queue_size: u16) -> u32 { 9 let seg_max = min(max(iov_max(), 1), u32::max_value() as usize) as u32; 10 11 // Since we do not currently support indirect descriptors, the maximum 12 // number of segments must be smaller than the queue size. 13 // In addition, the request header and status each consume a descriptor. 14 min(seg_max, u32::from(queue_size) - 2) 15 } 16