Afghan defence chief quits over attack, as Mattis flies in